sách gpt4 ăn đã đi

javascript - response.statusCode 和 response.status 的区别

In lại Tác giả: Walker 123 更新时间:2023-11-30 15:03:37 28 4
mua khóa gpt4 giày nike

我正在编写一个在单击按钮时显示对话框窗口的函数:这里是与状态和 statusCode 相关的代码段。

     if(response.status>300){
jQuery("#myModal").modal("show");
}khác{
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");
}khác{
vm.someFunction();
}

// it does not work although my statusCode was 500;

所以,我的问题是:status 和 statusCode 之间有什么区别,什么时候应该使用它们中的一些?

câu trả lời hay nhất

客户端(在浏览器中),并使用 XMLHttpRequest hoặc fetch,要使用的正确属性称为 response.status

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

还有服务器端,在 Node.js 中,使用 http.ServerResponse(为特定响应cài đặt状态代码),正确使用的属性也是称为 response.statusCode

关于javascript - response.statusCode 和 response.status 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46129307/

28 4 0
Walker 123
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress