Skip to content

Instantly share code, notes, and snippets.

@adamcjoiner
Last active November 19, 2024 09:09
Show Gist options
  • Save adamcjoiner/06a04c34f796c136201bc4d06dd12ac4 to your computer and use it in GitHub Desktop.
Save adamcjoiner/06a04c34f796c136201bc4d06dd12ac4 to your computer and use it in GitHub Desktop.
Use jQuery's $.ajax to ping a URL and report the response
$.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