Jquery定期页面刷新与事件驱动页面刷新

Jquery定期页面刷新与事件驱动页面刷新,jquery,html,page-refresh,event-driven,Jquery,Html,Page Refresh,Event Driven,我知道,在给定计时器的情况下,可以使用ajax定期刷新。但是,如何设置页面,使其仅在从服务器端触发/发生http请求时更新 所以你通常会这样做 定期页面更新: // Use a named immediately-invoked function expression. (function worker() { $.get('ajax/test.html', function(data) { // Now that we've completed the request schedu

我知道,在给定计时器的情况下,可以使用ajax定期刷新。但是,如何设置页面,使其仅在从服务器端触发/发生http请求时更新

所以你通常会这样做

定期页面更新:

// 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);
  });
})();
事件驱动页面更新:(仅当服务器发送响应时)


问题:你会怎么做?这可能吗?

在请求之间,服务器与客户端没有连接。如果您绝对想要事件驱动的请求,那么必须使用插件。我会选择定期的ajax请求。

如果您使用的是.net,请查看Signal。