Step 4 learn Ajax

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.