Answer the question
In order to leave comments, you need to log in
Using AJAX in a lengthy PHP script. How to implement?
The script takes a very long time to execute using a third party API. I would like to add interactivity. What is the best way to do this?
Answer the question
In order to leave comments, you need to log in
Doesn't fit in understanding yet.
Here, for example, is line-by-line processing of a file.
Can you give an example of how to split?
The acronym "AJAX" is indirectly related to your desires.
The required functionality can be achieved using multithreading.
Details about multithreading in PHP and how to use it are written in the answer - stackoverflow.com/questions/209774/does-php-have-t...
Need to load a page for the user and show that something is happening and the process is going on?
Then make page 1 that will show the interface to the user, and from this page send a request to page 2 that will communicate with the external API. Before starting the request on page 1, put some gif "Loading in progress ...", and after a successful ajax request, remove the gif and return the results of the request.
The long loading of page 2 will not interfere with quickly showing the interface of page 1 to the user.
If you really need to quickly execute the script on page 2, then you already need to think about multithreading, optimizing the work of the script itself, setting up the server, etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question