Ajax form not calling uploadProgress

This is my code:

HTML:

<form id="myForm" enctype="multipart/form-data" action="api/upload.php" method="POST">
    <input type="hidden" />
    <input id="upload" name="userfile" type="file" class="choose-file"/>
    <button class="choose-picture"></button>
    <div class="filename"></div>
    <input type="submit" class="send-button" value='' />
</form>

<div class="progress">
   <div class="bar"></div >
   <div class="percent">0%</div >
</div>
<div id="status"></div>

      

JS:

picUpload: function() {
    var bar = $(this.el).find('.bar');
    var percent = $(this.el).find('.percent');
    var status = $(this.el).find('#status');

    $(this.el).find('#myForm').ajaxForm({
        beforeSend: function() {
            status.empty();
            var percentVal = '0%';
            bar.width(percentVal);
            percent.html(percentVal);
        },
        uploadProgress: function(event, position, total, percentComplete) {

            alert('upload progress!');
            var percentVal = percentComplete + '%';
            bar.width(percentVal);
            percent.html(percentVal);
        },
        success: function(data) {
            //   console.log(data);
            document.cookie = "imagePath=" + data;
            var myCookie = document.cookie.replace(/(?:(?:^|.*;\s*)imagePath\s*\=\s*([^;]*).*$)|^.*$/, "$1");
            console.log(myCookie);

            $('.full-picture-col').html('<img src="' + data + '" class="img-responsive" />').fadeIn('slow');
            $('.left-picture-col').hide();
            $('.right-picture-col').hide();
        },
        error: function($form, options) {
            alert('Wystąpił błąd!');   
        }
    });

      

For some reason the uploadProgress function is not called. I've seen some similar problems here on stackoverflow, but this was about IE. I am currently working on Chrome and I have this problem.

I have the latest version of jquery.form.js.

+3
javascript jquery ajax ajaxform


source to share


No one has answered this question yet

Check out similar questions:

5129
How do I return a response from an asynchronous call?
2984
What is the difference between calling and submitting an application?
1744
Cancel Ajax requests with jQuery
1567
Converting form data to JavaScript object with jQuery
1273
How to handle redirect request after jQuery Ajax call
1137
How can I get jQuery to make a synchronous rather than asynchronous Ajax request?
1001
Is Safari iOS 6 caching $ .ajax results?
874
jQuery AJAX submit form
738
How do I make an AJAX call without jQuery?
694
JQuery Ajax file upload



All Articles
Loading...
X
Show
Funny
Dev
Pics