Recently reading ajax
You need something that is relatively basic. For more information, see
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<Meta name = "Generator" CONTENT = "EditPlus">
<Meta name = "Author" CONTENT = "">
<Meta name = "Keywords" CONTENT = "">
<Meta name = "Description" CONTENT = "">
<Script language = "javascript">
If (window. ActiveXObject) // if window declares a function
{
Function XMLHttpRequest () // does not need to be declared in firefox
{
Try {
// Return the object handle
Return new ActiveXObject ("MSXML2.XMLHTTP ");
Return new ActiveXObject ("Microsoft. XMLHTTP ");
} Catch (err ){
Alert ("XMLHttpRequest error ");
}
}
}
// Declare an ajax function. This is the ajax entry.
Function ajax (reqtype, url, asynch, respHandle)
{
$ Ajax = new XMLHttpRequest (); // a new xmlhttp pays attention to this function. Do you want to include var to indicate global variables?
If ($ ajax) // check whether new is successful
{
// View the type of submission
If (reqtype. toLowerCase ()! = 'Post '){
InitReq (reqtype, url, asynch, respHandle); // call an initialization Function
} Else
{
Var args = arguments [4]; // if it is post, a parameter should be required.
If (args! = Null & args. length> 0)
{
InitReq (reqtype, url, asynch, respHandle, args); // call an initialization Function
}
}
} Else
{
Alert ('ajax new error ');
}
}
Function initReq (reqType, url, bool, respHandle ){
Try {
$ Ajax. onreadystatechange = respHandle; // you can specify a variable if the function is successfully called.
$ Ajax. open (reqType, url, bool); // open address
If (reqType. toLowerCase () = "post") {// if it is post, it must be of the sending type.
$ Ajax. setRequestHeader ("Content-Type", "application/x-www-form-urlencoded; charset = UTF-8 ");