I am using AJAX at client side to make calls(POST calls) to multiple servlets of the same app. The spec requires an AJAX call to wait for some event to happen(at the server side) before this call completes. Meanwhile other AJAX calls are being made to some OTHER servlet(s) all of which get completed immediately.
The latter calls returns some data on completion without a hitch. However, when the former(the one which was waiting for an event) completes, it "tries" to return some data too, but it returns the output of the latter calls and that too more than once.
I am using POST for all these calls and suspect that "constant-handshaking" is behind all this. I have also tried flushing the stream but that didn't help either.
No it was a logical error. I was using the same XMLHttpRequest() object to make multiple calls. So while the former AJAX waited for a response(on event onreadystatechange), the latter call made a new object and used it. Hence, I'd get the last completed response(ResponseText) on any former calls.