"Kreisquadratur" <Uwe.Dauernheim@[EMAIL PROTECTED]
>
> I'm in the situation, that a user could take actions which will
> trigger several Ajax.Requests. The problem here is, that the browser
> should stay responsive, so I need the asynchronous feature but the
> responses from the server should not only have the same order as the
> requests, but I also have to wait for the first answer before I can
> send the second request. So like:
>
> Request 1
> Response to 1
> Request 2
> Response to 2
> Request 3
> Response to 3
>
The XMLHttpRequest function has a onreadystatechange property which you
can
use to test if it has completed successfuly (readyState=4). Put your
requests in an array and process the elements of this array in the event
handler. Somethin like:
// req assigned to the XMLHttpRequest object
var requests = [url1,url2,url3]
requests.reverse()
req.onreadystatechange = nextRequest
function nextRequest()
{ if ((req.readyState!=4) || (requests.length==0)) return
req.open("GET",requests.pop(),true)
}
Tom


|