jquery's ajax method, for GET requests, will splice the url and query parameters into http://xxx.xxx/aaa/bbb?arg1=ddd
to initiate the request.
I define a route like Route::get('aaa/bbb/{arg1}'). The request that this route can recognize is http://xxx.xxx/aaa/bbb/ddd.
For such a problem, how should laravel's routing be written to correctly respond to the front-end AJAX request?
Post the solved code memo:
Route:Route::get('getProjectInfoByAPI/{url?}', 'ProjectController@getProjectInfo');
front end:
$.ajax({
url: 'getProjectInfoByAPI',
type: 'GET',
data: {
url: xxx,
},
dataType: 'json',
success: function(response){
}
});
});
Route::get('/aaa/bbb/{arg1?}','UserController@arg1');
$.ajax({
routing
Controller in