I want to write a function for my website, which checks several web servers to see if they are online or not... I'm working with jQuery.ajax() I realized that I have to use JSONP, but i really dont know how to do that! I have an array of IP adresses and I want to check if the corresponding servers are available.
Here is my code so far:
function urlExists(url){
$.ajax({
timeout: 5000,
type: 'GET',
dataType: 'jsonp',
url: "http://" + url,
cache: false,
"error":function(XMLHttpRequest,textStatus, errorThrown) {
if(errorThrown == "timeout") {
alert("woah, there we got a timeout...");
// At this point the request shall abort
}
},
statusCode: {
404:function(){
alert("404!");
},
0:function(){
alert("0!");
},
500:function(){
alert("500!");
},
200:function(){
alert("it worked!");
}
}
});
}
urlExists("192.168.5.55");
After that i want to save whether the webserver is online or not, but where?