Javascript 服务器在Firefox中发送一次事件后不工作
以下是控制器中的Javascript 服务器在Firefox中发送一次事件后不工作,javascript,php,jquery,html,codeigniter,Javascript,Php,Jquery,Html,Codeigniter,以下是控制器中的get\u update方法的服务器端代码 header('Content-Type: text/event-stream'); header('Cache-Control: no-cache'); header('Connection: keep-alive'); ... $wait_time = gmdate('s', $query['max_wait']); echo "data: $wait_time\n\n"; flush(); javas
get\u update
方法的服务器端代码
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
header('Connection: keep-alive');
...
$wait_time = gmdate('s', $query['max_wait']);
echo "data: $wait_time\n\n";
flush();
javascript代码是(在jQuery中)
这是很好的工作在铬,甚至在前驱但问题是,它在firefox中更新一次后停止工作(重新加载工作一次,刷新完成后工作两次,停止后)。这里出了什么问题?这是firefox中的jquery问题。上述SSE代码在
$(document).ready()中。
此函数在Firefox中不能连续工作。我在这个函数外部生成了代码,现在运行得很好您是在$(document.ready()
外部还是内部调用了该函数?
var source = new EventSource('get_update');
source.onmessage = function (event) {
$('#total_logged').text(event.data);
};