1

I have a file which makes a huge Excel data sheet with more than 10.000 lines. I load the file with $.ajax method of jQuery.

$('#excelExportForm').submit(function(){
    $.ajax({        
        type: "GET",
        url: "phpexcel/export_titles.php",             
        dataType: "html",
        async: true,            
        success: function(response){                    
            console.log(response); 
        }
    });
    return false;
});

After every line a calculate the actual process in percent and echo it out.

How can I get this echo to manipulate a progress bar?

The Output in my console is the following:

000111112222233333444445555566666777778888899999101010101011111111111212121212131313131314141414141515151515161616161617171717171818181818191919191920202020202121212121222222222223232323232424242424252525252526262626262727272727282828282829292929293030303030313131313132323232323333333333343434343435353535353636363636373737373738383838383939393939404040404041414141414242424242434343434344444444444545454545464646464647474747474848484848494949494950505050505151515151525252525253535353535454545454555555555556565656565757575757585858585859595959596060606060616161616162626262626363636363646464646465656565656666666666676767676768686868686969696969707070707071717171717272727272737373737374747474747575757575767676767677777777777878787878797979797980808080808181818181828282828283838383838484848484858585858586868686868787878787888888888889898989899090909090919191919192929292929393939393949494949495959595959696969696979797979798989898989999999999100100
Thomas D.
  • 66
  • 5
  • You need to use some progress bar plugins for that – 웃웃웃웃웃 Mar 12 '14 at 13:01
  • dose `response` returns with progress percent only ? if so create css progress bar and update the div width on success – Kodr.F Mar 12 '14 at 13:04
  • Yes, it's only percent value. How can I update the progress bar if I only get the all percent values in my success callback? So I have a progress bar with 0% at start and with 100% at the end. But what's between? – Thomas D. Mar 12 '14 at 13:05
  • You need a diffrent approach, since you only get the response when the php file is fully loaded (in your example when 100 get echoed). Here is a good example using AJAX and php to get the progress of some task using **$_SESSION** http://stackoverflow.com/questions/20453015/progress-bar-ajax-and-php – Johnny000 Mar 12 '14 at 13:13
  • You can more easy send your information about progress with WebSockets. Is it possible in your case? – Andrey Korchak Mar 12 '14 at 13:20
  • I don't have any skills with WebSockets. It's a pity! – Thomas D. Mar 12 '14 at 13:52
  • This should work: http://www.dave-bond.com/blog/2010/01/JQuery-ajax-progress-HMTL5/ also note that there is an internal function `onprogress` that you can also try, although it's unsupported by jquery since it's not meant for public use, see the first comment from the above link – Populus Mar 12 '14 at 14:19
  • possible duplicate of [What is the cleanest way to get the progress of JQuery ajax request?](http://stackoverflow.com/questions/19126994/what-is-the-cleanest-way-to-get-the-progress-of-jquery-ajax-request) – Populus Mar 12 '14 at 14:22
  • Is the example of the dabe-bond blog not only for up-/downloads? I think the event listener is looking for a $_FILES-Array. Isn't it? It's the same like the possible duplicate. – Thomas D. Mar 12 '14 at 17:59

0 Answers0