I have created a simple php script that searches through (in my signature below) several whois servers (.com, .net, .info etc.) for the availability of a domain name. Additionally, I made the script look also for different other domain names by adding prefixes and suffixes to the search term. (E.g. if you look for the domain name boss.com, the script also looks for superboss.com and bossmatic.com). I have a list of 20 prefixes and 20 suffixes that the script is looking for at the moment, summing up more than 120 requests to the whois servers. My problem is that the browser waits for all the script to finish until displaying the full result. This might take a while (depending on the whois server charge) and it's not very nice for the user. What I would like, is to show the results one by one as received from the whois servers. For this I have tried to use flush() and ob_flush() functions in different manners, but with no result. I have tried: 1. ob_flush(); flush(); 2. ob_end_flush(); ob_flush(); flush(); ob_start(); 3. ini_set('output_buffering','on'); ini_set('zlib.output_compression', 0); 4. ob_flush(); flush(); ob_flush(); flush(); ob_flush(); flush(); 5. I have blocked gzip in htaccess <IfModule mod_gzip.c> mod_gzip_on no </IfModule> 6. I have checked php.ini for output buffer settings - they were accordingly. And many more flush workarounds as read on the internet. Unfortunatelly, no results. Recently I learned that only AJAX would solve my issue. I have read some tutorials, but I have no idea how to apply it in my special case. Could anyone give me some hints (both using flush function or AJAX)?
Send an AJAX request for server1. Have the PHP page process that and return the results. When the results are returned, have that trigger the code to send an AJAX request for server2. Etc. I've never tried to return partial AJAX results - I don't think you can.
Thanks, Rukbat. But I need a more specific answer . I have never used AJAX before. Another question: would it be possible to make flush work?
I don't think you can do it with flush(). Since I don't know what your Javascript looks like, all I can offer is that in the callback for each AJAX call, you start another AJAX call, with its own callback. (Once you're comfortable enough with AJAX, you can do it all in one call and one callback - sort of a state machine.) If you're using jQuery's ajax() function, in success you call the next ajax() function. You can nest the whole thing, or wrap each ajax() call in a Javascript function. The latter looks neater to human beings, but the browser won't really care either way.