Many of the suggestions below are very helpful but I would just like to clarify something.
If you are making calls to a .php script with AJAX (xmlHttpReq) and use flush, this will send data to your script HOWEVER it will not set the xmlHttpReq.readyState to 4 -- which is a requirement to use the information sent (Firefox does however allow you to use the responseText property with a readyState == 3 but IE will throw an error).
To get around this, you will need to make sure of a couple things:
In your Apache php.ini config file, check to make sure that output buffering is disabled:
output_buffering = off
Next, disable gzip compression for the .php script that is called from your AJAX script by using the excellent suggestion from Mandor by placing the following at the top of your script:
@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
What causes this problem is that while the php child process is running under apache, apache is waiting for the script to complete before completely closing the connection. Scripts that send information directly to the browser with echos and prints will get away with using flush followed by a sleep command and then clean up procedures. However, if you notice in the status bar of your browser window, the connection is still held open by apache until the script completed ("Transferring" ... yadda yadda).
By turning off the Apache compression, the connection is terminated directly after a flush while still giving the user the ability to run a sleep command followed by clean up code.
This bit me because the AJAX was returning <img> tags to newly created images by php. The cleanup script would then remove those images after completion.
Since Apache held the connection open, the readyState only changed to 4 AFTER my php cleanup fired -- thereby erasing the links referred to my the <img> tags.
With this solution, the readyState will change to 4 BEFORE the sleep command begins.
I hope this saves someone a lot of time and frustration. AJAX requests are an entirely different beast compared with simple outputting to a browser window.