Saturday, 15 March 2014

jquery - Wait until $.ajax completes without using $.when -


In my project I will have to use jQuery 1.4.x. I have four async $ Ajax functions are closed, and all are true / false I need to wait to evaluate them in IF, because if I do them now, not all firing has ended

code ( All in $ (document) .ready ..: `

  function getHTTPStatusCode200 (urlIn) {$ .ajax ({url: urlIn, full: function Xhr} {return (xhr.status == 200);}}}}}   

There are four of them, and I need to do something like this:

  if (getHTTPStatusCode200 (url) & Amp; amp; amp; .pptus code 401 (url) {warning ("this is done.");}   

`

$ When is not hard to duplicate the concept:

  var results = []; Function new result (results) {results.push (results); If (result. === 4) {Warning ("This is done.")}} Function getHTTPStatusCode200 (urlIn) {$ .ajax ({Url: urlIn, complete: function (xhr) {if (xhr Status === 200} {newResult (xhr);}}})}} Your other functions, each calling is newResult when    

No comments:

Post a Comment