-1

The thing i met with the ajaxForm plugin as following:

HTML:

<form id="uploadForm" method="post" enctype="multipart/form-data">
    <input type="file" directory webkitdirectory name="fileToUpload" />
</form>

JavaScript:

$("input[name='fileToUpload']").change(function() {
    var form = $('#uploadForm');
    form.attr('action', uploadURL);
    form.ajaxSubmit({
        uploadProgress: function(event, position, total, percentComplete) {
            var percentVal = percentComplete + '%';
            console.log('percentVal', percentVal);
        },
        complete: function(xhr) {
            console.log('completed');
        },
        success: function() {
            console.log('success!!!!');
        }
        });
    return false;
});

The problem is i cannot even set the uploadProgress, once this callback was set, i got the 405 Method Not Allowed error. But if i removed uploadProgress from the ajaxSubmit's options, only success and complete callback were left, the upload operation executed correctly.

That confused me a lot.

Howard
  • 4,474
  • 6
  • 29
  • 42

1 Answers1

0

Finally, i got the answer. It is about the cross-domain issue.

Once i deploy my apps in the same web-container, the issue was gone. But i still confused about this. Why the uploadProgress could not even set while sending cross-domain request?

Howard
  • 4,474
  • 6
  • 29
  • 42