Copy codeThe Code is as follows:
// Step 1: Create an XMLHttpRequest object
Var http_request;
Try
{
Http_request = window. ActiveXObject ("Microsoft. XMLHTTP ");
} Catch (e)
{
Try
{
Http_request = new XMLHttpRequest ();
} Catch (e)
{
Alert ("your browser does not support XMLHttpRequest ");
}
}
// Step 2: Specify the submitted url
Http_request.open ("get", "url", "true"); // get is the submission method, and true is the specified Asynchronous interaction on the server.
// Step 3: process the data returned by the server
Http_request.onreadystatechange = function () // callback function, which is called four times in total. The readtState changes to 0-> 1-> 2-> 3-> 4 (completed) in sequence );
{
If (http_request.readyState = 4) // The server completes processing.
{
If (http_request.status = 200) // The client has completed processing.
{
// Processing segment
}
}
}
// Step 4: SEND Parameters
Http_request.send (null); // sending Parameters