There is a php script that accesses the API and receives data from it for 5-10 seconds. Is it possible to somehow load this data as it is received on the client via ajax?
1 answer
Ajax works on a request-response system, so it’s not possible to receive data partially while php is running.
For a similar case, long requests did so.
- Asynchronous ajax to the heavy php script.
- This script writes the result to a file on the server.
- Meanwhile, ajax is launched every 2 seconds on a timer to read this file and refresh the page.
|