Well, this is just because onreadystatechange actually gets called multiple times by the object. The XmlHttp object will tell the script what's it doing, so you can (eventually) make some sort of "status bar" for your script, but I don't think it's needed to use a GUI for this and thus it's not important. Therefore, you only need to know when it's done, and that's where readyState == 4 is for.
A reference of the readyState property explains why you get this:
quote:
Originally posted by DevGuru XmlHttp object reference
The readyState property indicates the current state of the request. It returns a 4-byte integer.
This property is read-only and has the following defined values
* UNINITIALIZED(0)
The object has been created, but has not been initialized (the open method has not been called).
* LOADING(1)
The object has been created but the send method has not been called.
* LOADED(2)
The send method has been called and the status and headers are available, but the response is not.
* INTERACTIVE(3)
some data has been received. You can get the partial results using the responseBody and the responseText properties.
* COMPLETED(4)
All the data has been received, and is available.
If you compare this to your debug, you'll understand what's happening:
quote:
Function called: OnEvent_Signin
Post failed! - Uninitialized, you didn't call open() yet.
Posted info-> user=decosemail@email.com&status=online
Post failed! - Loading, you didn't call send() yet.
Post failed! - Loaded, the response is not available yet.
Post failed! - Interactive, some data has already been retrieved.
Received info-> heremail@hotmail.com offline - Completed, so you're function takes over as you can see.
Parsing...
Parse-> heremail@hotmail.com offline
My suggestion: leave out the else block. If you want to check for errors, use this instead:
code:
if(xmlhttp.readyState === 4) {
if(xmlhttp.status === 200) {
Debug.Trace('Received info-> ' + xmlhttp.responseText);
ParseResponse(xmlhttp.responseText);
} else Debug.Trace('Post failed!');
}