mercredi 24 février 2016

Route NotFoundException error using AJAX GET

I'm trying to make an Ajax call to retrieve some data, so in the JavaScript I have:

var url = 'http://ift.tt/1LcWywM' $.ajax({ cache: false, url: url, method: 'GET' }).done(function(response) { var data = jQuery.parseJSON(response); console.log(data); });

Then in my route I have:

Route::get('my/uri/{ID1}/{ID2}', 'MyController@getSomeData'); If I type the url in my browser the route works as expected and returns the data, but when called via the Ajax function I get

``` NotFoundHttpException in RouteCollection.php line 161:

in RouteCollection.php line 161
at RouteCollection->match(object (Request)) in Router.php line 750
at Router->findRoute(object(Request)) in Router.php line 659
at Router->dispatchToRoute(object (Request)) in Router.php line 635
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http \{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure }(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object (Request), object(Closure ))) in Pipeline .php line 124
at Pipeline->Illuminate\Pipeline\{closure }(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession ->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure }(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure }(object(Request)) in AddQueuedCookiesToResponse .php line 37
at AddQueuedCookiesToResponse ->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array (object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure }(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle (object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure }(object(Request)) in CheckForMaintenanceMode .php line 44
at CheckForMaintenanceMode ->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure }(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter (object(Request)) in Kernel.php line 87
at Kernel->handle(object( Request)) in index.php line 54

```

Any ideas why this is happening?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire