0

I developed a facebook application in PHP. The problem is that it takes 2 minutes to display the result. This might confuse the user, who sees a blank canvas and leaves.

I just want to echo a statement that it is still processing.

I tried flush(); and ob_flush(); and ob_start(); but it is of no use.

Is there any other simpler alternative to address my specific problem?

I tried this, but it did not work as well.

ob_implicit_flush(true); ob_end_flush(); for ($i=0; $i<5; $i++) { echo $i.'<br>'; sleep(1); } 

EDIT:

The above code works perfectly fine with IE and other Browsers. Only Chrome has this issue.

5
  • How about just showing the user a loading page, calculate the result in background and check via AJAX if it's ready? Commented Feb 15, 2011 at 23:29
  • possible duplicate of Using PHP how to echo content every certain amount of time? Commented Feb 15, 2011 at 23:29
  • 1
    Karthik: Are you using Chrome by any chance? Commented Feb 15, 2011 at 23:29
  • @Karthik: So you're using Chrome? This doesn't work in Chrome, it is a known issue. Should work in Firefox and Safari though, even IE if I remember correctly. Commented Feb 15, 2011 at 23:32
  • Thats good enough for me... anyways Chrome has less than 10% of the browser market share. Thanks for the tip Commented Feb 15, 2011 at 23:40

2 Answers 2

2

Convert it to an AJAX request, where you load a quick page which can have anything you want, and then loads in data from the slower page in the background.

flush() won't do what you want because it will return only part of the output and the client will tend to wait for the complete page.

Sign up to request clarification or add additional context in comments.

Comments

0

Call flush(); as often as required.

Unfortunately, this might or might not make the browser feel happy to display your stuff. Even on IE, the result isn't predictable.

Comments