4

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

1

1 Answer 1

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);
}
Sign up to request clarification or add additional context in comments.

2 Comments

Have this function a return?
This is the implementation of the above function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.