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.