Let's say I have a web interface for ping: it takes the host name / ip and the number of packets, starts the shell for ping with the given parameters and returns the original output from ping, washing the output buffer after each new line. Therefore I visit:
https:
and the browser displays the resulting rows gradually as they come back from ping.
Is it possible to put these results in turn, when they become available, in an arbitrary <pre> or <div> element?
My first attempt fills only the #results element after receiving the full server response:
$.get("/ping.php", {target: $('#ping_target').val(), num: $('#ping_num').val() }, function(responseText) { $("#results").html(responseText); } );
I read the following questions:
and I know that I could send x requests from 1 ping each instead of one request for x pings or so that I could write ping results to a temp file and release periodic requests to get the last state of the file. All of them are rather inelegant when the essence of the matter is one ping team.
In short, the question is: βCan I run one request, accept the resulting response stream and update the contents of the element with the new response data several times before it is completed?β It can be updated every time when any data is received, updated every milliseconds, updated after each new line, etc.
From my reading, the answer seems to be βno,β but I would like to confirm once and for all that this is not possible with jQuery. (Followup: is it possible to implement this feature for a single query without jQuery?)
Thanks!
source share