我正在编写一个函数,它在按钮单击上显示对话框:这里是与status和statusCode相关的代码段。
if(response.status>300){
jQuery("#myModal").modal("show");
}else{
vm.someFunction();
}
// when I run the code above I got result working, however when I wrote //the following:
if(response.statusCode>300){
jQuery("#myModal").modal("show");
}else{
vm.someFunction();
}
// it does not work although my statusCode was 500;所以,我的问题是:状态和statusCode之间有什么区别,以及我什么时候应该使用它们中的一些。
发布于 2017-09-09 10:01:04
客户端(在浏览器中),并使用XMLHttpRequest或fetch,正确的属性称为response.status。
在Node.js中,服务器端使用http.ClientRequest (在处理您使用Node.js发出的HTTP请求的响应时),要使用的正确属性称为response.statusCode
另外,在Node.js中,服务器端使用http.ServerResponse (为特定响应设置状态代码),要使用的正确属性也称为response.statusCode。
https://stackoverflow.com/questions/46129307
复制相似问题