Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7739223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:28:10+00:00 2026-06-01T08:28:10+00:00

I’m using HTML5’s Server Sent Events to push updates to my online clients. Everything

  • 0

I’m using HTML5’s Server Sent Events to push updates to my online clients. Everything works fine on Firefox and Chrome but with Safari there’s a loading wheel all the time. Maybe because he detect SSE as something loading in the page.

How can I say to Safari that SSE isn’t something that loads but simply a updating script so the user won’t see the loading wheel after the page is really loaded?

This is the live updated html page that the client is looking at:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>SSE Tester</title>
</head>
<body>
    <h1>SSE Output</h1>
    <div id="result"></div> 
    <h1>Debug Console</h1>
    <div id="status"></div>   
    <script>
    //SSE si compatible
    if(typeof(EventSource)!=="undefined")
    {
        var i = 1;
        var source=new EventSource("demo_sse.php");



        //Lorsque le serveur envoie un message
        source.onmessage=function(event)
        {
            //Validation de l'origine du serveur
            if (event.origin != 'https://secure.mydomain.com') 
            {
                document.getElementById("status").innerHTML+= "<br><b>Oups! Looks like something went wrong!\n\nPlease contact webmaster@mydomain.com with the following error :</b><p><pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The Origin of the EventSource wasn\'t coming from our secure server!</pre>";
                return;
            }
            document.getElementById("result").innerHTML+= "#" + i + " " + event.data + "<br />";            
            i++;
        }   

        //EventListener
        source.addEventListener('message', function(e)
        {
            console.log(e.data);
            //document.getElementById("status").innerHTML+= "Message Recevied<br />";
        }, false);

        source.addEventListener('open', function(e) 
        {
            // Connection was opened.
            document.getElementById("status").innerHTML+= "Connection #" + i + " opened<br />";
        }, false);

        source.addEventListener('error', function(e)
        {
            if (e.readyState == EventSource.CLOSED)
            {
                // Connection was closed.
                document.getElementById("status").innerHTML+= "Connection closed by the server<br />";
            }
            else
            {
                // Error.
                document.getElementById("status").innerHTML+= "<b>Error Connection interrupted</b><br />";
            }
        }, false);
    }
    else
    {
        document.getElementById("result").innerHTML="Sorry, your browser does not support server-sent events...";
    }     

    </script>    
</body>
</html>

And there’s the code of my demo_sse.php script (server side):

<?php
$clientLatest = "1";
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
while(true)
{
    //Retreive latest version
    $filename = "version.txt";
    $handle = fopen($filename, "r");
    $serverLatest = fread($handle, filesize($filename));
    fclose($handle);

    if ($clientLatest < $serverLatest)
    {
        //Update client 
        $time = date("H:i:s");
        echo "data: Updating to Version: $serverLatest because client's Version: $clientLatest at: {$time}\n\n";
        $clientLatest = $serverLatest;
        ob_flush();
        flush();
    }   
    //sleep( rand(2, 7));
    sleep(1);
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:28:11+00:00Added an answer on June 1, 2026 at 8:28 am

    Looks like using javascript’s timeout fonctions fixed the problem in safari. Simply timeout the script before connecting for 1000ms so the loading seems completed for safari and then connect to SSE server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.