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

  • Home
  • SEARCH
  • 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 943121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:23:08+00:00 2026-05-15T22:23:08+00:00

I’m experimenting with Comet and I’m stuck with implementing it via a hidden IFrame

  • 0

I’m experimenting with Comet and I’m stuck with implementing it via a hidden IFrame (“forever frame”.

This is my index.html:

<!DOCTYPE HTML>
<html>
  <head>
    <script type="text/javascript">
    cometResponse = function() {
        var debugOut = document.getElementById('debugOutput');
        return function(response) {
            debugOut.innerHTML = response.number; 
        }
    }
    </script>
  </head>
  <body>
    <div id="debugOutput"></div>
    <iframe src="comet.php"></iframe>
  </body>
</html>

And this is the comet.php file:

<?php
set_time_limit(0);
header('Content-Type: text/html');
header('Cache-Control: no-cache, must-revalidate'); 
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Transfer-Encoding: chunked');
flush();
ob_flush();

$response = '<script type="text/javascript">
parent.cometResponse({
    number: %1$d
});
</script>';

for ($i = 0; $i < 2; $i++) {
    sleep(1);
    $data = sprintf($response, $i);
    $output = strtoupper(dechex(strlen($data)))."\r\n".$data."\r\n";
    echo $output;
    flush();
    ob_flush();
}
echo "0\r\n\r\n";

After loading the page, the browser seems to “wait” for the response. After a few seconds, Firebug shows an empty response with these response headers:

HTTP/1.1 200 OK
Date: Mon, 26 Jul 2010 09:34:04 GMT
Server: Apache/2.2.14 (Win32) PHP/5.2.12
X-Powered-By: PHP/5.2.12
Cache-Control: no-cache, must-revalidate
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Transfer-Encoding: chunked
Vary: Accept-Encoding
Content-Encoding: gzip
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: text/html;charset=ISO-8859-2

Since the response is treated as empty, the tag that should be in the response doesn’t get executed either.

However, if I remove the “Transfer-Encoding: chunked” header, the content is sent to the browser correctly but all in one big piece at the end of the script, as expected.

I just can’t find what’s going wrong here.

  • 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-05-15T22:23:09+00:00Added an answer on May 15, 2026 at 10:23 pm

    Two guesses:

    1. Content-Encoding: gzip

      Maybe mod_gzip does not work correctly?
      Have you tried on annother host?

    2. Maybe Firefox ignores the code, if
      it is not within < html>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.