XMLHttpRequest for Ajax

Source: Internet
Author: User
VaR Doc;
Window. onload = function ()
{
If (window. activexobject)
{
Doc = new activexobject ("Microsoft. XMLHTTP ");
}
Else if (window. XMLHttpRequest)
{
Doc = new XMLHttpRequest ();
}
}

Function Test ()
{
Doc. Open ("get", "/ajax/test. aspx", false );
Doc. onreadystatechange = function ()
{
If (Doc. readystate = 4)
{
If (Doc. Status = 200)
{
Document. getelementbyid ("DDD"). innerhtml = Doc. responsetext;
}
Else
{
Document. getelementbyid ("DDD"). innerthml = "server return status:" + Doc. statustext;
}
}
Else
{
Document. getelementbyid ("DDD"). innerhtml = "Please wait .";
}
}
Doc. Send (null );
}

Aspx File

Protected void page_load (Object sender, eventargs E)
{
Response. Write ("output content! ");
}

 

 

In addition, you can call multiple methods of An ASPX file:

Call time:
Doc. Open ("get", "/ajax/test. aspx? Id = 1 ", false );
Add Parameters

 

Aspx file code:

Protected void page_load (Object sender, eventargs E)
{
String id = request ["ID"];
If (ID = 1)
Response. Write ("result 1 ");
Else if (ID = 2)
Response. Write ("result 2 ");
}

 

 

Unfortunately, I Know That Ajax Based on XMLHttpRequest cannot support Firefox. I have found a lot of information, but I can use ajaxpro to better use the jquery library, it is also based on httprequest, but does not know how it is implemented.

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.