Create an XMLHTTP object. Differences between IE and Mozilla browsers
Copy codeThe Code is as follows: function getRequest (){
Http_request = false;
If (window. XMLHttpRequest ){
// Create XMLHttpRequest for Mozilla, Netscape, Safari, and other browsers
Http_request = new XMLHttpRequest ();
If (http_request.overrideMimeType ){
// If the server response header is not text/xml, you can call other methods to modify the header.
Http_request.overrideMimeType ('text/xml ');
}
} Else if (window. ActiveXObject ){
// Create XMLHttpRequest for Internet Explorer
Try {
Http_request = new ActiveXObject ("Msxml2.XMLHTTP ");
} Catch (e ){
Try {
Http_request = new ActiveXObject ("Microsoft. XMLHTTP ");
} Catch (e ){}
}
}
Return http_request;
}
//Get the Url's responseText
Copy codeThe Code is as follows: function getResponseText (url)
{
Http_request = getRequest ();
Http_request.open ('get', url, false );
Http_request.send (null );
If (http_request.readyState = 4)
{
// Receives the complete Server Response
If (http_request.status = 200 ){
// The HTTP server response value is OK.
Requestdoc = http_request.responseText;
// Write the string returned by the server to the region where the ID is message on the page.
}
Else {
Requestdoc = http_request.status;
}
}
Return requestdoc;
}
//Obtain the Url's responseXML Copy codeThe Code is as follows: function getResponseText (url)
{
Http_request = getRequest ();
Http_request.open ('get', url, false );
Http_request.send (null );
If (http_request.readyState = 4)
{
// Receives the complete Server Response
If (http_request.status = 200 ){
// The HTTP server response value is OK.
Requestdoc = http_request.responseXML;
// Write the string returned by the server to the region where the ID is message on the page.
}
Else {
Requestdoc = http_request.status;
}
}
Return requestdoc;
}