gpt4 book ai didi

javascript - http 获取请求状态

转载 作者:行者123 更新时间:2023-11-28 21:08:19 26 4
gpt4 key购买 nike

我正在使用 jQuery 发送 HTTP 请求。下面是代码。我想获取HTTP请求的状态码。

有人知道如何获得状态吗?

    $(document).ready(function(){
var url="http://www.google.com";
$.get(url, function(data,status) {
alert(status);
// This doesn't alert me status
// I want to alert request status code as "200" i.e. ok
});
// on Failure also need the status code of this request.
});

最佳答案

更新

<小时/>

Working Example

<小时/>
$.get(url, function(data,status, xhr) {
alert(xhr.status);
});

关于javascript - http 获取请求状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9331629/

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