Answer the question
In order to leave comments, you need to log in
PHP to JS Dataflow?
Please tell me how to get data stream from one php script for getJSON(jQuery).
I need the php script to not wait until it completes its work on the server and send data in json format, but constantly send data in a cycle, but at the same time continue to work. And javascript parsed the stream and packaged it into cells ...
Analog: the php script finished processing one cycle, received data, sent it with a variable (again), which means call me again, I didn’t finish, javascript received data, packages and checks if the variable is equal to 'again' calls json.php again. But this implementation is not entirely correct. I need speed optimization.
Who has any ideas?
Answer the question
In order to leave comments, you need to log in
caniuse.com/websockets as a client
php.net/manual/en/book.sockets.php + multithreading (pthread) or multiplexing (socket_select and the other way).
if you are too lazy to write the server, you can simply send the response in pieces and process it manually on the client side .
Here is an example of a server code that spits out content as it comes in:
https://github.com/nazar-pc/CSTester/blob/master/src/nazarpc/CSTester.php#L240
str_repeat(' ', 1024 * 64)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question