mercredi 29 juin 2016

laravel 5 ajax error request

Hi I was wondering why my Laravel 5 Ajax request doesnt work

        <input type="hidden" class="_token" value="" name="_token">

 $.ajax({
          url: "",
          method: 'post',
          data: {
            name: 'name',
            _token: $("input[name=_token]").val()
          },
          success: function(response) {
            if (response.success == true) {
              // remove error message
              alert('success');
            }
          },
          error: function(xhr) {
              alert('error');
            }
          });

on the Route File I put:

    Route::post('search/store', [
        'uses' => 'SearchController@store',
        'as' => 'groups.store'
    ]);

and on my controller I put:

public function store(Request $request)
    {
        return response()->json(['success' => true]);
    }

then I keep getting error 404 while I simply wants to display the json result from my controller much help appreciated thx



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire