I have a jQuery script that polls my server for new data, but it needs to display an error message if for some reason it doesnβt work.
Here is my AJAX request:
$.ajax({
url: "query.php",
cache: false,
error: function() {
$(".status").text("Server is offline.");
},
success: function(html) {
}
});
I found that if you rename query.php, so it is not available, the error function starts and a message is displayed. However, if I take the web server offline, the error function does not start.
How can I adapt my code to detect when a node is unavailable?
source
share