AJAX Progressive Output

I have a very large file that takes about 5 minutes to download. Its strictly an administrator script, however, I am currently creating a user interface for interacting with the administrator. I want this script to run in the user interface via AJAX. Currently, the PHP script has:

@apache_setenv('no-gzip', 1); @ini_set('zlib.output_compression', 0); @ini_set('implicit_flush', 1); for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); } ob_implicit_flush(1); 

Thus, it is gradually displayed through the browser.

However, my AJAX call (using jQuery) looks like this:

 $.ajax({ url: "theURL", success: function(data){ $(".content").html(data); } }); 

And it is displayed only after the script is finished. How to get AJAX to use progressive output?

+4
source share
1 answer

I think that you will need to use a web worker (JavaScript is running in the background), for example:

 w = new Worker("demo.js"); 

where demo.js is JavaScript in the background.

Please see: http://www.w3schools.com/html/html5_webworkers.asp

0
source

Source: https://habr.com/ru/post/1380162/


All Articles