0

环境: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>
4

0 回答 0