在此記錄下:
正常情況下我們的data:$('#form').serialize(),但是這個只是序列化了表單的數據,不帶上file文件,並且,我們需要使用原生的JS獲取form( document.getElementById),這和JQ的$('#form') 獲取到的對象的節點不一樣
var formData = new FormData(document.getElementById(form)); $.ajax({ type: "post", url: href, data: formData, dataType: "json", async: true, cache: false, processData: false, contentType: false, success: function (result) { if (result) { if (result.IsSuccess == true) { $('#' + modal).modal('hide');
感謝:
https://www.cnblogs.com/wei-dong/p/7570624.html
