2012-07-31 02:24:19 +00:00
|
|
|
// Updates a div with a specified id, by polling an url,
|
|
|
|
// which should return a new div, with the same id.
|
2012-07-30 22:01:41 +00:00
|
|
|
|
|
|
|
connfails=0;
|
|
|
|
|
2012-07-31 00:33:23 +00:00
|
|
|
function longpoll(url, divid, cont, fail) {
|
2012-07-31 00:22:10 +00:00
|
|
|
$.ajax({
|
|
|
|
'url': url,
|
|
|
|
'dataType': 'html',
|
|
|
|
'success': function(data, status, jqxhr) {
|
|
|
|
$('#' + divid).replaceWith(data);
|
|
|
|
connfails=0;
|
|
|
|
cont();
|
|
|
|
},
|
|
|
|
'error': function(jqxhr, msg, e) {
|
|
|
|
connfails=connfails+1;
|
|
|
|
if (connfails > 3) {
|
2012-07-31 00:33:23 +00:00
|
|
|
fail();
|
2012-07-30 22:01:41 +00:00
|
|
|
}
|
2012-07-31 00:22:10 +00:00
|
|
|
else {
|
|
|
|
cont();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2012-07-30 22:01:41 +00:00
|
|
|
}
|