Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've had similar problems working heavily with SharePoint web services - you often need to pull data from multiple sources before you're able to continue working.</p> <p>To solve it I embedded this kind of functionality into my AJAX abstraction library. You can easily define a request which will trigger a set of handlers when complete. However each request can be defined with multiple http calls. Here's the component:</p> <p><a href="http://depressedpress.com/javascript-extensions/dp_ajax/" rel="nofollow">DPAJAX at DepressedPress.com</a></p> <p>This very simple example creates one request with three calls and then passes that information, in the call order, to a single handler:</p> <pre><code> // The handler function function AddUp(Nums) { alert(Nums[1] + Nums[2] + Nums[3]) }; // Create the pool myPool = DP_AJAX.createPool(); // Create the request myRequest = DP_AJAX.createRequest(AddUp); // Add the calls to the request myRequest.addCall("GET", "http://www.mysite.com/Add.htm", [5,10]); myRequest.addCall("GET", "http://www.mysite.com/Add.htm", [4,6]); myRequest.addCall("GET", "http://www.mysite.com/Add.htm", [7,13]); // Add the request to the pool myPool.addRequest(myRequest); </code></pre> <p>Note that unlike many of the other solutions provided this method does not force single threading of the calls being made - each will still run as quickly as the environment allows but the handler will only be called when all are complete. The component also supports user-defined numbers of requests so you can force single-threading easily if you like. It also supports the setting of timeout values and retry attempts if your service is a little flakey.</p> <p>I've found it insanely useful (and incredibly simple to understand) for this kind of work.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload