gpt4 book ai didi

javascript - XMLHttpRequest 未发送

转载 作者:行者123 更新时间:2023-12-03 00:13:11 25 4
gpt4 key购买 nike

我们是三位开发人员,正在使用 Django 开发 Web 应用程序项目。

一些通信客户端-服务器使用 API。某一特定请求未在开发人员的一台计算机上发送。我们使用相同的浏览器(FirefoxQuantum 64.0(64位)),相同的操作系统(Ubuntu 18.04)。

这是 JS 片段:

function requestHandler(url){
let xhttp = new XMLHttpRequest();
xhttp.open('POST', url, true);
xhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhttp.setRequestHeader('X-CSRFToken', getCookie('csrftoken'));

xhttp.onreadystatechange = function(){
if (this.readyState == 4 && this.status == 200) {
drawLogTable();
}
else if (this.readyState == 4){
console.log(this);
new PNotify({
title: 'Échec!',
text: "Opération impossible: " + this.statusText,
type: 'error'
});
}
}
xhttp.send();
}

请注意,url'../../api/log?action=accept&id=1'

在所有工作计算机和浏览器上,请求都会发布并执行 404,因为服务器端尚未实现。在非工作计算机上,chromium 可以工作,但在 Firefox 下,请求甚至没有发送(服务器日志为空)并且请求对象完全为空(没有状态,没有文本)。

我们还有其他运行良好的相同类型的 AJAX 请求。

最佳答案

你能试试这个吗:

 xhttp.onload = function(){
if (this.status == 200) {
drawLogTable();
}

关于javascript - XMLHttpRequest 未发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54630164/

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