0
由于某种原因,我的表单在第一次“提交”时提交一次,然后在第二次提交时提交两次,如果不提交刷新两者之间的页面。ajax表格在第二次提交时提交两次,第三次提交时提交3次等
$(document).on('submit', ".post-video-form", function(uploadVideo) {
uploadVideo.preventDefault();
var formData = new FormData($(this)[0]);
$.ajax({
type: 'post',
url: '/dev/new/scripts/upload_video.php',
data: formData,
success: function (response) {
if (response == 'success') {
$(".overlay").fadeOut(200);
setTimeout(function() {
$(".overlay").remove();
}, 250);
setTimeout(function() {
$(".head").before(overlay_success_html);
$(".overlay").fadeIn();
}, 255);
$(document).on('click', ".close-overlay", function(){
$(".overlay").fadeOut(200);
setTimeout(function() {
$(".overlay").remove();
}, 250);
});
}
if (response == 'failed') {
$(".upload-error").append('Upload error: File must be a JPG or PNG less than 2.0MB');
}
},
error: function() {
$(".upload-error").append('Upload error: File must be a JPG or PNG less than 2.0MB');
},
cache: false,
contentType: false,
processData: false
});
});