Batch AJAX requests to REST endpoint

870 views Asked by At

I want to send many GET requests to a REST endpoint (implemented with ArcGIS), with a change in the parameters, e.g.:

http://<root-url>/query?where=param=foo    
http://<root-url>/query?where=param=bar    
http://<root-url>/query?where=param=baz    
...

Instead of iterating through a for loop and sending that many AJAX requests, is it possible to send a batch request to the API or do some pipeling?

1

There are 1 answers

0
Murtaza Hussain On

Using jQuery.when, to execute ajax request when all requests have completed then respond using response handlers.

$.when($.ajax("request1"),
    $.ajax("request2"),
    $.ajax("request3"))
.done(function(data1,  data2, data3) {
   // Do something with the data
 });

For more info on jQuery.when.

Thanks.