Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Feb 2009
    Posts
    24
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Different results from safari, ie and chrome!

    Hi all!

    I'm creating some AJAX POC's here at work, and I've run across this issue; but first, this is what I'm POC'ing...

    #1. Create a html page that used Javascript to connect to my backend via AJAX and get the data it needs. This I have working in a limited fastion.

    #2. I need to stream the data back to me, like "server says '1'", then "2" etc until it says 100.

    #3. So I created a simple script that I call from the browser to test this "streaming"

    This is the sample code

    Code:
    #!/usr/bin/perl
    $| = 1;
    print "Content-type: text/html\r\n\r\n";
    print "<html>";
    print "<head>";
    print "<title>Callback Test #1</title>";
    
    print '<meta content="no-cache" http-equiv="pragma"/>';
    print '<meta content="-1" http-equiv="expires"/>';
    
    print "</head>";
    print "<body>";
    print "<div id='myData'>";
    print "Empty!";
    print "</div>";
    
    for($i=0;$i<10;$i++)
    {
        print "<script language='JavaScript'>\r\n";
        print "document.getElementById('myData').innerHTML='Counter is [$i]';\r\n";
        print "</script>\r\n";
        sleep(1);								     
    }
    
    print "</body>\n";
    print "</html>\n";
    On Firefox, I see the numbers 0~9 being displayed ()
    On Safari and Chrome, it just shows the last one, but does wait the correct time...

    I would guess that they are not processing the javascript tags realtime?

    This is the sample "backend" I will use in my AJAX demo...

    Thoughts?

    ~Kam (^8*

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,860
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Could you post the parsed output(html+javascript) taken from browser's view source option?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Feb 2009
    Posts
    24
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Here is the output when it is all done

    Code:
    <html><head><title>Callback Test #1</title><meta http-equiv="Pragma" content="no-cache"/><meta http-equiv="Expires" content="-1"/></head><body>Version 1.1.0<br><br><br><div id='myData'>Empty!</div><script language='JavaScript'>
    document.getElementById('myData').innerHTML='Counter is [0]';
    </script>
    <script language='JavaScript'>
    document.getElementById('myData').innerHTML='Counter is [1]';
    </script>
    <script language='JavaScript'>
    document.getElementById('myData').innerHTML='Counter is [2]';
    </script>
    <script language='JavaScript'>
    document.getElementById('myData').innerHTML='Counter is [3]';
    </script>
    <script language='JavaScript'>
    document.getElementById('myData').innerHTML='Counter is [4]';
    </script>
    <script language='JavaScript'>
    document.getElementById('myData').innerHTML='Counter is [5]';
    </script>
    <script language='JavaScript'>
    document.getElementById('myData').innerHTML='Counter is [6]';
    </script>
    <script language='JavaScript'>
    document.getElementById('myData').innerHTML='Counter is [7]';
    </script>
    <script language='JavaScript'>
    document.getElementById('myData').innerHTML='Counter is [8]';
    </script>
    <script language='JavaScript'>
    document.getElementById('myData').innerHTML='Counter is [9]';
    </script>
    </body>
    </html>
    ~Kam (^8*

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,860
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    OK, try
    Code:
     print "document.getElementById('myData').innerHTML+='Counter is [$i]';\r\n";
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •