<span style="white-space:pre"> </span>var form = new FormData(document.getElementById("form_fabu"));
$.ajax({
type: "POST",
url:"{:U('Usercenter/sellgood')}",
//data:$('#form_fabu').serialize(),
data:form,
enctype:"multipart/form-data",
async: false,
cache: false,
processData: false,
<span style="white-space:pre"> </span>contentType: false,
error: function(request) {
alert("添加失败");
},
success: function(data) {
if(data=="Y"){
<span style="font-family: Arial, Helvetica, sans-serif;">alert("添加成功");</span>
}
}
可能服务器会出现报错 TypeError: 'append' called on an object that does not implement interface FormData.
只要加上两个option
<pre name="code" class="javascript"><span style="white-space:pre"> </span>processData: false,
<span style="white-space:pre"> </span>contentType: false,
就可以了