0

My AJAX request runs a PHP script which calls several functions. Each function queries a different API, generates some HTML based on the results, and populates an array. At the end of the script, the values from the array are added to a database.

Since the functions can take a good chunk of time, I would like my AJAX to display the HTML as it is being generated, i.e. after each function is completed. At the same time, I would like to only have one AJAX request because I need to add all the values to my database at the end.

Hopefully this makes some sense – is what I'm trying to do even possible? Could anyone suggest a solution/workaround/anything to point me in the right direction? Thanks!

vinsanity555
  • 241
  • 1
  • 11

1 Answers1

0

Make sure the server side code doesn't buffer output, and don't wait until the XHR readyState has reached 4 before you start making use of responseText.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335