jQuery.post dynamic data callback function

Posted by FFish on Stack Overflow See other posts from Stack Overflow or by FFish
Published on 2010-04-12T18:59:46Z Indexed on 2010/04/12 19:03 UTC
Read the original article Hit count: 291

Filed under:
|
|
|

I have a script that requires quite e few seconds of processing, up to about minute. The script resizes an array of images, sharpens them and finally zips them up for the user to download.

Now I need some sort of progress messages. I was thinking that with jQuery's .post() method the data from the callback function would progressively update, but that doesn't seem to work.

In my example I am just using a loop to simulate my script:

        $(document).ready(function() {
            $('a.loop').click(function() {
                $.post('loop.php', {foo:"bar"},
                function(data) {
                    $("div").html(data);                        
                });
                return false;
            });
        });

loop.php:

for ($i = 0; $i <= 100; $i++) {
    echo $i . "<br />";
}
echo "done";

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about post