Support the ongoing development of Laravel.io →
posted 10 years ago
Requests
Last updated 3 years ago.
0

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.

0
Solution

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

Last updated 10 years ago.
0

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;
        }
      }
Last updated 10 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

maxehnert maxehnert Joined 28 Apr 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.