首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >response.statusCode与response.status的区别

response.statusCode与response.status的区别
EN

Stack Overflow用户
提问于 2017-09-09 09:46:06
回答 1查看 3.8K关注 0票数 3

我正在编写一个函数,它在按钮单击上显示对话框:这里是与status和statusCode相关的代码段。

代码语言:javascript
复制
     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之间有什么区别,以及我什么时候应该使用它们中的一些。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-09-09 10:01:04

客户端(在浏览器中),并使用XMLHttpRequestfetch,正确的属性称为response.status

在Node.js中,服务器端使用http.ClientRequest (在处理您使用Node.js发出的HTTP请求的响应时),要使用的正确属性称为response.statusCode

另外,在Node.js中,服务器端使用http.ServerResponse (为特定响应设置状态代码),要使用的正确属性也称为response.statusCode

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46129307

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档