createxmlhttprequest.js

来自「这是基于jsp的相册管理系统。数据库是mysql」· JavaScript 代码 · 共 37 行

JS
37
字号

// 创建XMLHttpRequest对象
function createXMLHttpRequest()
{
    var xmlRequest = false;
	//开始初始化XMLHttpRequest对象
	if(window.XMLHttpRequest) 
	{ //Mozilla 浏览器
	    xmlRequest = new XMLHttpRequest();
	    if (xmlRequest.overrideMimeType)
	     {//设置MiME类别
	       xmlRequest.overrideMimeType('text/xml');
	     }
	}
	else if (window.ActiveXObject)
	{ // IE浏览器
			try 
			{
			    xmlRequest = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) 
			{
					try 
					{
							xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
					} 
					catch (e) {}
			}
	}
	if (!xmlRequest) 
	{ // 异常,创建对象实例失败
			window.alert("不能创建XMLHttpRequest对象实例.");
			return false;
	}
	return  xmlRequest;
}
//end XMLHttpRequest的创建

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?