Home >Backend Development >PHP Tutorial >Method to create XMLHttpRequest object_PHP tutorial

Method to create XMLHttpRequest object_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:36:28754browse

Method 1: Recommendation

//Create a Boolean variable

var xmlhttp = false;

// Check whether you are using IE browser

try{

// If the JS version is greater than 5

xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

alert("You are using Microsoft Internet Explorer.");

}catch(e){

// If not, use the old version of ActiveX object

try{

// If you are using IE browser

xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

alert("You are using Microsoft Internet Explorer.");

}catch(e){

// Use a non-IE browser

xmlhttp = false;

}

}

// If you are using IE non-browser

if(!xmlhttp && typeof XMLHttpRequest != undefined){

xmlhttp = new XMLHttpRequest();

alert("You are not using Microsoft Internet Explorer.");

}

Method 2:

var xmlhttp;
// If the ActiveX object is available, the IE browser must be used
(!window.ActiveXObject){
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}else{
// Use Javascript method to process

http://www.bkjia.com/PHPjc/508226.html

www.bkjia.com

http: //www.bkjia.com/PHPjc/508226.htmlTechArticleMethod 1: Recommended // Create a Boolean variable var xmlhttp = false; // Check whether you are using IE Browser try{ // If the JS version is greater than 5 xmlhttp = new ActiveXObject("Msxml2.X...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn