Is there a way to set a handler function for when a set of events has happened?

Posted by allyourcode on Stack Overflow See other posts from Stack Overflow or by allyourcode
Published on 2010-03-15T20:18:45Z Indexed on 2010/03/15 20:59 UTC
Read the original article Hit count: 235

Filed under:
|
|
|

eg I have two concurrent AJAX requests, and I need the result from both to compute a third result. I'm using the Prototype library, so it might look something like this:

var r1 = new Ajax.Request(url1, ...);
var r2 = new Ajax.Request(url2, ...);

function on_both_requests_complete(resp1, resp2) {
   ...
}

One way would be to use polling, but I'm thinking there must be a better way.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about AJAX