0

In my webpage when I click on the button, the request goes through ajax on my server on php file. Below is the php file.

Now as you can see that it has many echo statements, so while the server is processing data my webpage has to wait while php file completes its processing.

Is there any technique by which handle each echo statement simultaneously?

Meaning, I don't need to wait for whole response and I can append each part of the response to my webpage.

<?php
$i = 0;
while($i<1000000){
echo $i;
$i++;
}
?>
dbugger
  • 15,868
  • 9
  • 31
  • 33
Nikunj Acharya
  • 767
  • 8
  • 19
  • How about storage the values in a file? then, the ajax request can read this file while the server still working in the rest of process – manix Jun 08 '14 at 20:28
  • Yes. There is a technique. This will put you on the right path, then you can come back with questions after you've programmed something and have more code to show. http://stackoverflow.com/questions/3880381/xmlhttprequest-responsetext-while-loading-readystate-3-in-chrome – Stephen Jun 08 '14 at 20:28
  • bt in my case probebly it will not work. see i am making websites regarding flats details . in this websites if user is quering something it will go on server via ajax now on server that query will run and produce multiple echo statements each having flat id,flat image source,flat catagory and many other things , now if there are 1000 such flats. i have to wait till it process all data . bt i want that when it echo 1st detail of the falt i should get responce and i will append it to div then 2nd flat den 3rd flat and so on. so user dnt need to wait for all flats . – Nikunj Acharya Jun 08 '14 at 20:38
  • thanks stephen your link is good and i think my problem will be solved.. i m studying it – Nikunj Acharya Jun 08 '14 at 20:44
  • 2
    You can flush after every echo and read the changes in readyState 3 from the XHR. – inf3rno Jun 08 '14 at 20:44
  • http://www.binarytides.com/ajax-based-streaming-without-polling/ – zerkms Jun 08 '14 at 20:44

0 Answers0