当前位置:编程学习 > JS >>

帮帮忙关于ajax的

搜索栏调用onkeyup="GetAjaxData()"后代码如下 怎么实现无刷新搜索查询中文,现在只能查英文

<script type="text/jscript">
   
        var xhr = null;
        function CheckBrowser() {
            if (window.XMLHttpRequest) {
                xhr = new XMLHttpRequest();
            }
            else {
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
            }
        }
        function GetAjaxData() {
            var keyword = document.getElementById("Text1").value;
            var url = "panduanyemian.aspx?keyword=" + keyword;
            CheckBrowser();
            xhr.onreadystatechange = Handler;
            xhr.open("post", url, true);
            xhr.send(null);
        }
        function Handler() {
            //4代表回调成功
            if (xhr.readyState == 4) {
                //代表成功返回服务器加载的信息
                if (xhr.status == 200) {
                    //显示结果
                    var result = xhr.responseText;
                    document.getElementById("xianshi").innerHTML = result;
                }
            }
        }
    </script>

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