laravel: routing any ajax request
Posted: Tue Dec 08, 2015 8:48 am
Hi There,
I'm working on laravel 4.2.
Here, I've been processing ajax request from route as:
URLs are as:
However, this above route is starting to get clumsy. If I've 10 such request, I'm dumping and making routes php page a pure mess.
I'd like to so something:
I've following issues:
1) here I'd like to send URL to the process_ajax function too
I'm unable to get this into working.
I'm working on laravel 4.2.
Here, I've been processing ajax request from route as:
Code: Select all
Route::group(['prefix' => 'illumina', 'namespace' => 'Controllers\\illumina','before' => 'pims_auth'], function() {
if(Request::ajax()){
Route::get('illumina_xhr_get_samples','mainIllumina@get_illumina_samples');
Route::post('submit_isolate_analysis','mainIllumina@submit_isolate_analysis'); //called from js->illumina->grid.js
}
});
And so on. That is prefixed with 'illumina/'url:'illumina/illumina_xhr_manage_samples',
url:'illumina/illumina_xhr_get_samples'
However, this above route is starting to get clumsy. If I've 10 such request, I'm dumping and making routes php page a pure mess.
I'd like to so something:
Code: Select all
if(Request::ajax()){
Route::match(array('GET','POST') do something);
//pass any request to mailIllumina controller's process function
}
1) here I'd like to send URL to the process_ajax function too
I'm unable to get this into working.