you can have a 'key' for the data to determine which data to be saved on which table.
something like data: [{'region': localStorage.regions, 'marker': localStorage.markers}]
with that, you can use only one request.
Like @beanmoss said, I think 1 POST request can do the job. But if you really need to, you could also do this,
var request1 = $.ajax({
url: '/wave/markers',
// ...
});
var request2 = $.ajax({
url: '/wave/regions',
// ...
});
$.when(request1, request2).then(function (response1, response2) {
// response1, response2 should each contain an array with length of 3, [ data, statusText, jqXHR ]
// your logic goes here
});
Route::post('wave/markers', 'WaveController@markers');
Route::post('wave/regions', 'WaveController@regions');
That's what REST should do isn't it? :D
Thank you I will give these suggestions a try.
edit: This worked thanks.
Route::post('wave/regions', 'WaveController@storeRegions');
Route::post('wave/markers', 'WaveController@storeMarkers');
public function storeRegions (Request $request)
{
if($request->ajax()) {
$data = $request->all();
return $data;
}
}
public function storeMarkers (Request $request)
{
if($request->ajax()) {
$data = $request->all();
return $data;
}
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community