Today I saw the attributes of XMLHttpRequest:
onReadyStateChange
This event is triggered when the state is changed, and JavaScript functions are usually invoked.
Status has 5 values: 0: Uninitialized. 1: Loading. 2: Already loaded. 3: the interaction. 4: Finished.
ResponseTest
The response of the server, expressed as a string.
Responsexml
The response of the server, expressed as XML
Status
The status number of the server HTTP (200 corresponds to ok,404 is not found.) There are a lot of people who can go on
NET look for ... ................
Statustest
The status text of the server HTTP (ok,not Found. There are a lot of people can surf the internet to find
Have a look for ...............
=============================================================================
=
A simple example:
The client triggers an AJAX event.
<input type= "text" id= "email" name= "Send Mail" onblur= "Validateemail ()";>
=========================================================
Here is the Validateemail function:
var xmlHttp;
function Validataemail ()
{
var Email=document.getelemenbyid ("email");
var url= "validate?email=" + Escape (email.value);
if (window. ActiveXObject)
{
Xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");
}
else if (window. XMLHttpRequest)
{
Xmlhttp=new XMLHttpRequest
}
Xmlhttp.open ("get", url);
Xmlhttp.onreadystatechange=callback;
Xmlhttp.send (NULL);
}
'***********************************************************************/
' * Function Name:callback *
' * Input Arguments: * *
' * Out Arguments: * *
'* : */
' * Description: Check the ReadyState property of the XMLHttpRequest to see the status code returned by the server. */
' * Author: * *
' * date:2006-11-30 *
'***********************************************************************/
function callback ()
{
if (xmlhttp.readystate==4)
{
if (xmlhttp.status==200)
{
Do what you want to do.
}
}
}