Sunday 15 May 2011

how to use jQuery.when() with multiple jsonp requests? -


I have two cross domain JSP requests that need to be completed before executing any other method. So I tried $. When () function

  $ When (getX (), getY ()) Then (createXY);   

getX () and getY () $ .jax () Request two different domains with different jsonp callbacks.

Unlike my original idea, Excloses gets before callback return.

Does anyone provide me an example when using a function when multiple async jsonp requests are completed?

$ When working for () , it should be passed to the deferred object which it is waiting for. Make sure that your getX () and getY () functions are returning to the deferred object created by jQuery's AJAX call, which makes each.

If you want to help in doing so, then post the code for getX () and getY () .

Here's an example:

  $ When ($. Ajax ("/ page1.php"), $ .ajax ("/ page2.php")) done (function (a1, a2) {/ * a1 and a2 are page 1 and page 2 of ajax requests Resolved logic for, respectively, * / var jqXHR = a1 [2]; / * logic ["success", status text, jqXHR] * / if (/ alert / test (jqXHR.responseText)) {warnings (" The first page has 'alerts somewhere'.);}});    

No comments:

Post a Comment