javascript - 我的代码在某些更改后停止工作
问题描述
我试图在 xhr.send(data); 成功后重新加载页面;
但我认为那失败了
var xhr = new XMLHttpRequest();
xhr.open('POST', "User/adde", true);
xhr.onload = function(){
if (xhr.status==403 || xhr.status==404) {
alert("ERROR LOADING 3-UPLOAD.PHP");
} else {
//alert(this.response);
}
};
xhr.send(data); // the data will send from here.
success: function(data){
if(data.success == true){ // if true (1)
setTimeout(function(){// wait for 5 secs(2)
location.reload(); // then reload the page.(3)
}, 5000);
}
}
解决方案
推荐阅读
- javascript - TypeError:无法读取未定义的scanner.js的属性“扫描”
- laravel - Laravel:分页后是否可以使用 eagerloading?
- blazor - 如何将 HTML 属性(类等)添加到 Blazor 组件?
- docker - “Docker-compose run”显示后端正在运行,但无法从主机访问
- android - Android:写日志文件的库?
- apache-spark - 将后缀附加到 PySpark 行
- kotlin - 使用 gradle 约定插件设置 kotlin jvmTarget 选项
- shell - 如何在shell中转换变量中的字符串
- lua - printf("%s\n", lua_tostring(L, -1)); 遇到分段错误
- php - 跳过修改 CTE 并返回现有键而不是插入新键(如果值已存在)