ajax ie8没有触发回调

时间:2013-08-05 19:04:37

标签: c# asp.net ajax internet-explorer-8

环境:winXP,vs08,ie8

为什么我的回叫没有解雇?

<div>
    <input id="Button1" type="button" value="button" onclick="myjs()" />
</div>
</form>
<script type="text/javascript">
    function myjs() {
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4 && xhr.status == 200) {
                xhrCallback(xhr.responseText);
            }
        }
        xhr.open("POST", "Handler.ashx", true);
        xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xhr.send("x=" + 1 + "&y=" + 2);
    }

    function xhrCallback(retval) {
        alert('test');
    }

</script>

0 个答案:

没有答案