1

I am working on iWidget Development using dojo, and I have to show multiple data sets from different REST Calls. Is there any possibility that I can call multiple REST Get Calls in one dojo.xhrGet call and have an array of responses? Or if some one can lead me to best way of calling multiple REST Services at one time?

Bridge
  • 29,818
  • 9
  • 60
  • 82
emarshah
  • 328
  • 3
  • 14

2 Answers2

0

Xhr = XMLHttpRequest = One Request ! You could start multiple request at the same time though, but the browser limits the number of multiple async requests in some way:

How many concurrent AJAX (XmlHttpRequest) requests are allowed in popular browsers?

OR:

Your server could do the multiple requests for your widget and provide it with the data in only one request, but you would have to look into how to run them concurrently (=saves time) !

Community
  • 1
  • 1
Lucian Depold
  • 1,999
  • 2
  • 14
  • 25
0

Which version of dojo are you using? Depending on the version you want to use a dojo.DeferredList or dojo/promise/all. The xhrGet function already returns a deferred, so you could have code like this :

new dojo.DeferredList([dojo.xhrGet({url:"http://first.rest.url/here}), doo.xhrGet({url:"http://second.rest.url/here"})])
.then(function(results){
    // do something with your results array here
})
Frances McMullin
  • 5,516
  • 2
  • 18
  • 19