简体   繁体   English

http获取请求状态

[英]http get request status

I am using jQuery for sending HTTP request. 我正在使用jQuery发送HTTP请求。 Below is the code. 下面是代码。 I want to get the status code of HTTP request. 我想获取HTTP请求的状态码。

Does anyone know, how to get the status? 有人知道如何获得身份吗?

    $(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.
    });

Update 更新资料


Working Example 工作实例


$.get(url, function(data,status, xhr) {
    alert(xhr.status);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM