I check my Internet connection with this function and call it periodic using timeinterval()
function check_dc(){
clearInterval(id);
id=setInterval("check_dc()",5000);
$.ajax({
url: 'http://www.google.com/',
type: 'GET',
error: function(){
flag=0;
alert("DC");
},
success: function(res, textStatus, xhr) {
var headline = $(res.responseText).find('a.tsh').text();
flag=1;
alert((res.responseText));
}
});
}
I set a flag if my request successes and reset it when failed. But when I disconnect from Internet to test the error function I can't see the alert also when I add beforeSend attribute just like error, I can't see it either!
p.s: I use jquery.xdomainajax to have cross domain request