Answer the question
In order to leave comments, you need to log in
Why doesn't the SSE script work?
There is no output of any information. Naturally, except for the UPD text))) It seems that I am doing everything right. Maybe some libraries on the server are needed?
client side
<h1>UPD</h1>
<div id='console'></div>
<script>
var eventSource = new EventSource('https://test/myphp.php');
eventSource.onmessage = function(e) {
console.log(e);
};
eventSource.onerror = function(e) {
console.log(e);
};
</script>
Header('Content-Type: text/Svent-stream');
header('Cache-Control: no-cache');
$data = "server time: ".date("h:i:s", time());
print "data: ".$data. PHP_EOL; echo PHP_EOL;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question