AJAX

//创建
var httpChg;
GetXmlHttpObject = function(statechg){
    var xmlHttp = null;
    try {
        //  IE7+、Firefox、Chrome、Safari 以及 Opera
        xmlHttp = new XMLHttpRequest();
    } 
    catch (e) {
        // 老版本的 Internet Explorer (IE5 和 IE6)
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    if (xmlHttp == null) {
        alert("您的浏览器不支持AJAX!");
    }
    else {
        xmlHttp.onreadystatechange = function(){
            if (xmlHttp.readyState == 4) {
                statechg();
            }
        }
    }
    return xmlHttp;
}

function ChgUser(servlet, jsname){
	httpChg = GetXmlHttpObject(jsname);
	httpChg.open('GET', servlet + '&' + Math.random(), true);
	httpChg.send();
}

//返回
function sbackdel(){
                //接收信息
	var TELS = httpChg.responseText;
	var arr = new Array();
	arr = TELS.split(",");
}

相关推荐