我发送带有文件和来自FORM的输入的邮件,我使用ajax并且一切正常,这是一个漫长的过程,所以我想添加progressBar,问题是:
uploadProgress:从不调用函数(event,position,total,percentComplete)。
任何想法?
AJAX:
var options = {
beforeSend: function()
{
$("#progress").show();
//clear everything
$("#bar").width('0%');
$("#percent").html("0%");
},
uploadProgress: function(event, position, total, percentComplete)
{
console.log("in uploadprogress");
console.log(total);
console.log(percentComplete);
$("#bar").width(percentComplete+'%');
$("#percent").html(percentComplete+'%');
},
success: function()
{
alert('Form submitted');
$("#bar").width('100%');
$("#percent").html('100%');
},
error: function()
{
// The request failed - So do something here
alert('Form NOT submitted'); //display an alert whether the form is
console.log('form not submited ERROR');
}
};
$("#myForm").ajaxForm(options);
我使用了console.log(“在uploadprogress中”)并且没有记录任何内容。也使用警报,但没有显示......