HTTP Status Code from URL in Javascript - Stack Overflow

I'm trying to find a function that return HTTP Status Code from an URL, and then "make someth

I'm trying to find a function that return HTTP Status Code from an URL, and then "make something" based on the returned statuses (404, 416, 200 etc...)

Can someone help me? I've tried the other functions posted here on StackOverflow but anyone was usefull for my purpose.

I need to integrate this function inside my PlayFramework web-app.

Thanks a lot

I'm trying to find a function that return HTTP Status Code from an URL, and then "make something" based on the returned statuses (404, 416, 200 etc...)

Can someone help me? I've tried the other functions posted here on StackOverflow but anyone was usefull for my purpose.

I need to integrate this function inside my PlayFramework web-app.

Thanks a lot

Share asked Mar 17, 2015 at 11:23 FabioFabio 1591 gold badge4 silver badges13 bronze badges 1
  • if using jquery, this is the answer : stackoverflow./a/8571617/724913 – arkoak Commented Mar 17, 2015 at 11:28
Add a ment  | 

1 Answer 1

Reset to default 1

Can you try the following ..?

function getStatus(url) {
        var request = new XMLHttpRequest();
    request.onreadystatechange = function() {
        if (request.readyState === 4){
            request.status;//this contains the status code
        }
    };
request.open("GET", url , true);
request.send(null);
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744907695a4600356.html

相关推荐

  • HTTP Status Code from URL in Javascript - Stack Overflow

    I'm trying to find a function that return HTTP Status Code from an URL, and then "make someth

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信