function ajax(url, onsuccess, onfail) {
    var xmlHttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = function () {
        if (xmlHttp.readyState == 4) {
            if (xmlHttp.status == 200) {
                onsuccess(xmlHttp.responseText);
            }
            else {
                onfail(xmlHttp.status);
            }
        }
    }
    xmlHttp.send();
}

posted on 2014-02-24 15:47  麻衣之光  阅读(1034)  评论(0编辑  收藏  举报