Mozilla サポートの検索

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

詳しく学ぶ

このスレッドはアーカイブに保管されました。 必要であれば新たに質問してください。

Handling event streams

  • 1 件の返信
  • 1 人がこの問題に困っています
  • 40 回表示
  • 最後の返信者: cor-el

more options

I am trying to get server sent event streams working.

As a test, I placed the following in a php file:

header('Content-Type: text/event-stream'); header('Cache-Control: no-cache'); // recommended to prevent caching of event data.

function sendMsg($msg) {

 echo "data: $msg" . PHP_EOL;
 echo PHP_EOL;
 flush();

}

sendMsg('server time: ' . date("h:i:s"));

When I load the page into FireFox (95.0.2 (64-bit)), it asks me if I want to save or open the file. Obviously it isn't handling the event stream properly (or my code is wrong)

I am trying to get server sent event streams working. As a test, I placed the following in a php file: header('Content-Type: text/event-stream'); header('Cache-Control: no-cache'); // recommended to prevent caching of event data. function sendMsg($msg) { echo "data: $msg" . PHP_EOL; echo PHP_EOL; flush(); } sendMsg('server time: ' . date("h:i:s")); When I load the page into FireFox (95.0.2 (64-bit)), it asks me if I want to save or open the file. Obviously it isn't handling the event stream properly (or my code is wrong)

すべての返信 (1)

more options

選ばれた解決策