原生态Ajax(转)
原文链接:一次Ajax查错的经历
function InitAjax (){
var ajax=false;
try {
ajax = new ActiveXObject ("Msxml2.XMLHTTP");
} catch (e) {
try {
ajax = new ActiveXObject ("Microsoft.XMLHTTP");
} catch (E) {
ajax = false;
}
}
if (!ajax && typeof XMLHttpRequest!='undefined') {
ajax = new XMLHttpRequest ();
}
return ajax;
}
var ajax = InitAjax ();
ajax.open ("GET", url, true);
ajax.onreadystatechange = function() {
if (ajax.readyState == 4 && ajax.status == 200) {
var show = document.getElementById ("HaoChenDIV") .value;
show.innerHTML = ajax.responseText;
}
}ajax.send (null);