Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 服务器在Firefox中发送一次事件后不工作_Javascript_Php_Jquery_Html_Codeigniter - Fatal编程技术网

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);
};