One. What is Ajax?
Ajax is read without flush data.
Two. The principle of Ajax:
HTTP request method
1.get-used to get data (e.g. Browse posts)
2.post-for uploading data (e.g., user registration)
Three. Writing the AJAX request:
The idea of Ajax requests
1. Creating an Ajax Object
IE6 or more
var oajax=new xmlhttprequest ();
IE6
var oajax=new activexobject ("Microsoft.XMLHTTP");
Resolving IE6 compatibility issues
var oajax=null;
if (window. XMLHttpRequest)
{
Oajax=new XMLHttpRequest ();
}
Else
{
Oajax=new ActiveXObject ("Microsoft.XMLHTTP");
}
2. Linked Servers
Open (method, URL, whether asynchronous)
Oajax.open (' GET ', ' abc.txt ', true);//Where abc.txt is the path
3. Sending the request
Oajax.send ();
4. Receive return
Oajax.onreadystatechange=function ()
{
if (oajax.readystate==4)
{
if (oajax.status==200)
{
Alert (' success: ' +oajax.responsetext);
}
Else
{
Alert (' failure ');
}
}
};
};
which
Request Status Monitoring
onReadyStateChange Events
ReadyState Properties: Request Status
>0 (uninitialized) has not yet called the Open () method
>1 (load) called the Send () method, sending the request
>2 (loading complete) the Send () method completed, received all response content
>3 (parsing) parsing response content
>4 (completion) Response content resolution completed, you can invoke the Status property on the client: request result ResponseText
Status property: Request result
ResponseText
Talking about Ajax