If you send two asynchronous requests in quick succession I presume this involves two different instances of the XMLHttpRequest.

Are you supposed to allocate a different onsteadystatechange function to each different instance of XMLHttpRequest (which seems a bit awkward). I have tried to use a single "pipe-like" function and then try and identify the instance that caused the event by inspecting event properties such as window.event.srcElement. This yields null.

Maybe one could keep an array of request object instances and test then one at a time for correct readystate to find which request has returned.

Any "right" way of doing this. Many thanks.

Qavo,

You can write a single function and attach it as the handler for onsteadystatechange to different instances of XMLHttpRequest.

Inside the handler, refer back to the instance of XMLHttpRequest that fired it with this . See http://www.w3.org/TR/XMLHttpRequest/

Of course, if you need to do very different things onsteadystatechange in each instance of XMLHttpRequest, then attach different functions.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.