【编者按】:网学网Ajax为您提供XMLHttpRequest of ajax参考,解决您在XMLHttpRequest of ajax学习中工作中的难题,参考学习。
调用 function(Url) {
var XML = new XMLHttpRequest();
XML.onreadystatechange = function() {
if (XML.readyState == 4)
{
if (XML.status == 200)
{
//XML.responseText
}
else
{
//XML.statusText
}
}
else
{
//数据加载中...
}
};
XML.open("GET",Url);
XML.send(null);
};定义XMLHttpRequest 适应不同的浏览器 // IE support
if (window.ActiveXObject && !window.XMLHttpRequest)
{
window.XMLHttpRequest = function()
{
var msxmls = new Array(''Msxml2.XMLHTTP.5.0'',''Msxml2.XMLHTTP.4.0'',''Msxml2.XMLHTTP.3.0'',''Msxml2.XMLHTTP'',''Microsoft.XMLHTTP'');
for (var i = 0; i < msxmls.length; i++)
{
try
{
return new ActiveXObject(msxmls[i]);
}
catch (e)
{
}
}
return null;
};
}
// Opera support
if (window.opera && !window.XMLHttpRequest)
{
window.XMLHttpRequest = function()
{
this.readyState = 0; // 0=uninitialized,1=loading,2=loaded,3=interactive,4=complete
this.status = 0; // HTTP status codes
this.statusText = '''';
this._headers = [];
this._aborted = false;
this._async = true;
this._defaultCharset = ''ISO-8859-1'';
this._getCharset = function()
{
var charset = _defaultCharset;
var contentType = this.getResponseHeader(''Content-type'').toUpperCase();
val = contentType.indexOf(''CHARSET='');
if (val != -1)
{
charset = contentType.substring(val);
}
val = charset.indexOf('';'');
if (val != -1)
{
&