gpt4 book ai didi

javascript - 我的 onReadyStateChange 从未被调用,为什么?

转载 作者:行者123 更新时间:2023-12-02 19:16:23 25 4
gpt4 key购买 nike

我的代码很简单。

function useXMLHttpRequest() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "test.ashx", false);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
xmlhttp.onReadyStateChange = function () {
alert("ss");
};
xmlhttp.send("i=5");
alert(xmlhttp.responseText);

}

当我调用 useXMLHttpRequest.Yes 时,它会提醒 xmlhttp.responseText 的值。但它不警报(“ss”)。在 IE9 和 Firefox 中均如此。谁能告诉我穿的是什么?

最佳答案

JavaScript(以及我所知道的所有其他语言)区分大小写,因此 onreadystatechangeonReadyStateChange不同。

试试这个:

xmlhttp.onreadystatechange = function() {
alert("ss");
};

关于javascript - 我的 onReadyStateChange 从未被调用,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13081272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com