zoukankan      html  css  js  c++  java
  • Ajax代码

    function GetXmlHttpObject() {
        var xmlHttp = null;
        try {
            // Firefox, Opera 8.0+, Safari
            xmlHttp = new XMLHttpRequest();
        }
        catch (e) {
            // Internet Explorer
            try {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
        }
        return xmlHttp;
    }

    function GetInfo() {

        var xmlHttp = GetXmlHttpObject();

        if (xmlHttp == null) {
            alert("您的浏览器不支持AJAX!");
            return;
        }

        var keystr = document.getElementById("keyword").value;

        var url = "InfoService.aspx";
        url += "?key=" + encodeURI(keystr);
        url += "&type=" + tempType;
        url = url + "&r=" + Math.random();

        xmlHttp.onreadystatechange = function() {
            if (xmlHttp.readyState == 4) {
                //                 try {
                var f = xmlHttp.responseText;
                ShowMsg(f);
                //                 }
                //                 catch (ex) {
                //                     alert("发生意外错误:"+ex);

                //                 }
            }
        };
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    }

  • 相关阅读:
    Java实现 LeetCode 394 字符串解码
    Java实现 LeetCode 394 字符串解码
    Java实现 LeetCode 392 判断子序列
    Java实现 LeetCode 392 判断子序列
    Java实现 LeetCode 392 判断子序列
    Java实现 LeetCode 391 完美矩形
    Java实现 LeetCode 391 完美矩形
    Java实现 LeetCode 391 完美矩形
    Java实现 LeetCode 390 消除游戏
    Java实现 LeetCode 390 消除游戏
  • 原文地址:https://www.cnblogs.com/dashi/p/4034765.html
Copyright © 2011-2022 走看看