這裏提交表單是我的形式jQuery的變化事件中使用AJAX
<form name="uploadImg" id="uploadImg" class="profile-image" enctype="multipart/form-data">
<input type="file" name="profile" id="updProfileImg">
</form>
,這裏是我的jQuery事件
$("#updProfileImg:file").change(function() {
$('#uploadImg').submit(function() {
var queryString = new FormData($('form')[0]);
$.ajax({
type: "POST",
url: 'index.php?route=account/edit/upload',
data: queryString,
contentType: false,
processData: false,
beforeSend: function() {
},
success: function() {
}
})
})
})
但變化事件不會觸發表單提交,所以我嘗試trigger('submit')
但頁面刷新,而不是提交在Ajax中。
嘗試切換返回功能? –