I understand that you can refresh with ajax, periodically pulling, given a timer. But how do you set up a page to update only when an http request which has triggered/happened from the server side?
So you would typically do this
Periodic page Update:
// Use a named immediately-invoked function expression.
(function worker() {
$.get('ajax/test.html', function(data) {
// Now that we've completed the request schedule the next one.
$('.result').html(data);
setTimeout(worker, 5000);
});
})();
Event Driven page Update: (only when server sends response)
Question: How would you do this? Is this possible?