function connect(){
$.ajax({
data : {'timestamp' : timestamp},
url : url,
type : 'get',
timeout : 0,
success : function(response){
var data = eval('('+response+')');
error = false;
timestamp = data.timestamp;
$("#content").append('<div>' + data.msg + '</div>');
},
error : function(){
error = true;
setTimeout(function(){ connect();}, 5000);
},
complete : function(){
if (error)
// if a connection problem occurs, try to reconnect each 5 seconds
setTimeout(function(){connect();}, 5000);
else
connect();
}
})
}
$.ajax({
data : {'timestamp' : timestamp},
url : url,
type : 'get',
timeout : 0,
success : function(response){
var data = eval('('+response+')');
error = false;
timestamp = data.timestamp;
$("#content").append('<div>' + data.msg + '</div>');
},
error : function(){
error = true;
setTimeout(function(){ connect();}, 5000);
},
complete : function(){
if (error)
// if a connection problem occurs, try to reconnect each 5 seconds
setTimeout(function(){connect();}, 5000);
else
connect();
}
})
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货