var createXHR = function() {
	var xhr, last_e;
	var PROGIDS = [
		"Msxml2.XMLHTTP.6.0", 
		//"Msxml2.XMLHTTP.5.0",    // 此版本目的是给MS Office App使用, 
					   // Web中用会弹出安全对话框
		
		"Msxml2.XMLHTTP.4.0",    // Have issues, a buggy version
		"Msxml2.XMLHTTP.3.0", 
		"Msxml2.XMLHTTP",
		"Microsoft.XMLHTTP"    // The oldest version
	];
	var len = PROGIDS.length, i = 0;
	
	if(window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		for( ; i < len; ++i ) {
			try {
				xhr = new ActiveXObject(PROGIDS[i]);
				return xhr;
			} catch(e) {
				last_e = e
			}
		}
	}

	throw new Error(last_e);
};

 Firefox 1+, Opera 8+, Safari 1.2+, and Internet Explorer 7+ 开始支持 Native XMLHttpRequest Object.

优先使用XMLHttpRequest, 因为其更高效.

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
  • 2022-02-20
  • 2022-01-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-16
  • 2021-07-03
  • 2022-12-23
  • 2021-10-17
  • 2021-08-04
相关资源
相似解决方案