As suggested here: https://gist.github.com/HenrikJoreteg/2502497, I\'m trying to add onprogress functionality to my jQuery.ajax() file upload. The upload works
This is a bit of a hack of another answer elsewhere on Stack Overflow, but I think answers your question. I have doctored it to my own needs of pumping "streamed" data from the server to a scrollable div (which I can then force to always scroll to the bottom thus showing progress over time and thus not waiting for the entire record set to complete).
The client side code below adds the resulting content to a predefined div with id "scrollable_area" (which can then be scrolled)...
The server side "your_api_call.php" file call would need to then flush its output (per data row so as to see progress over time) which can then be displayed immediately within the above "scrollable_area" div...
// Do Db loop
while ($record = $recordset->fetch(PDO::FETCH_ASSOC)) {
set_time_limit(10); // Don't timeout on large data sets seeing as this is a big task that we are wanting to watch progress!
echo 'Do what you gotta do... ' . $record["register_id"] . '
';
flush(); // Push to the client / ajax
ob_flush(); // As above
}
Short answer... YES. Hope this helps :-)