如何处理PHP-AJAX响应文本?

时间:2015-08-08 13:06:36

标签: javascript php ajax

下面是我使用ajax(index.html)调用php文件

idiv

这是我的verify.php文件

<html>
    <head>
    <title>Test Page</title>
    <script>
        function verify_data() {
            var xmlhttp = new XMLHttpRequest();
            xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {         
                    //do nothing
                }
            }
            var data_id = document.getElementById("data_id").value;
            xmlhttp.open("GET", "verify.php?query=" + data_id, true);
            xmlhttp.send();
        }
    </script>
</head>
<body>
    <div id="box1">Demo Content</div>
    <input type="hidden" name="data_id" id="data_id" value="23"/>
    <button onclick="verify_data();">Verify</button>
</body>

我知道无法重定向用户或从被调用页面更改主html页面的内容。 我认为可以通过处理ajax响应文本来完成,但我不知道该怎么做。

0 个答案:

没有答案
相关问题