gpt4 book ai didi

javascript - XMLHttpRequest.open() 方法中的错误函数不正确

转载 作者:行者123 更新时间:2023-12-03 06:08:00 28 4
gpt4 key购买 nike

我对本地 http 服务器进行了 ajax 调用,但在 xmlhttp.open("GET", "http://localhost//push", true); 中出现错误IE 11 中的函数不正确,下面是我的完整代码:

var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
....some code.....
}}
}
xmlhttp.open("GET", "http://localhost//push", true);
xmlhttp.send();
}

IE 使用new XMLHttpRequest();

最佳答案

最后我得到了一个非常愚蠢的问题的答案,在 chrome 中 URL 可以是 "http://localhost//push" 但在 IE 中应该有 反斜杠 而不是正斜杠 "http:\\localhost\\push" 否则会显示错误的函数

关于javascript - XMLHttpRequest.open() 方法中的错误函数不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39450213/

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