Last active
November 19, 2024 09:09
-
-
Save adamcjoiner/06a04c34f796c136201bc4d06dd12ac4 to your computer and use it in GitHub Desktop.
Use jQuery's $.ajax to ping a URL and report the response
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({url: "http://www.google.com/", | |
type: "HEAD", | |
timeout:1000, | |
statusCode: { | |
200: function (response) { | |
console.log('Status 200: Page is up!'); | |
}, | |
400: function (response) { | |
console.log('Status 400: Page is down.'); | |
}, | |
0: function (response) { | |
console.log('Status 0: Page is down.'); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment