26 lines
508 B
Text
26 lines
508 B
Text
|
// Uses long-polling to update a div with id=poll.
|
||
|
// The PollR route should return a new div, also with id=poll.
|
||
|
|
||
|
(function( $ ) {
|
||
|
|
||
|
$.LongPoll = (function() {
|
||
|
return {
|
||
|
send : function() {
|
||
|
$.ajax({
|
||
|
'url': '@{PollR}',
|
||
|
'dataType': 'html',
|
||
|
'success': function(data, status, jqxhr) {
|
||
|
$('#poll').replaceWith(data);
|
||
|
setTimeout($.LongPoll.send, 3000);
|
||
|
},
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}());
|
||
|
|
||
|
$(document).bind('ready.app', function() {
|
||
|
setTimeout($.LongPoll.send, 40);
|
||
|
});
|
||
|
|
||
|
})( jQuery );
|