当前位置:编程学习 > 网站相关 >>

最简单的实现ajax提交和获取

function AjaxGetXml(serviceUrl, soapAction, data) {
    var xmlHttp;
    try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e) {
        try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
        catch (e) {
            try { xmlHttp = new XMLHttpRequest(); }
            catch (e) { return null; }
        }
    }
    try {
        var url = serviceUrl + "/" + soapAction;
        xmlHttp.open("POST", url, false);
        xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xmlHttp.send(data);
        if (xmlHttp.status != 200) {
            return null;
        }
        try //Internet Explorer 
        {
            var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async = "false";
            xmlDoc.loadXML(xmlHttp.responseText);
            return xmlDoc;
        } catch (e) {
            try //Firefox, Mozilla, Opera, etc. 
            {
                parser = new DOMParser();
                return parser.parseFromString(xmlHttp.responseText, "text/xml");
            } catch (e) {
                return null;
            }
        }
    }
    catch (e) {
        return null;
    }
}

欢迎访问:http://121.18.78.216适易查询分析、工作流、内容管理及项目管理演示平台

补充:综合编程 , 其他综合 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,