对未实现接口FormData的对象调用“append”

我正在尝试使用jquery和ajax上传图像。但奇怪的事情发生在这里。在控制台日志中显示它

TypeError:对未实现的对象调用了“append”
接口FormData

请告诉我我做错了什么

JS脚本

var prosrc=$(“#pro#pix img”).last().attr(“src”);
$(“#logoform”)。关于('change',函数(事件){
var postData=新表单数据(本);
$(“#pro#pix img”).last().hide();
$(“#pro#pix img”).first().show();
event.preventDefault();
$.ajax(
{
url:“/function/pro_pic_upload.php”,
类型:“POST”,
数据:postData,
成功:函数(数据、文本状态、jqXHR)
{
$(“#pro#pix img”).last().show();
$(“#pro#pix img”).first().hide();
$(“#pro#pix h6”)。文本(数据);
},
错误:函数(jqXHR、textStatus、errorshown)
{
//如果失败
}
});
});

我的HTML标记

<div class=“行”>
<!--左栏-->
<div id=“pro_pix”class=“col-md-4 col-sm-6 col-xs-12”>
<div class=“文本中心”>
<img src=”https://stackoverflow.com/questions/25390598/template/image/725.GIF“class=“头像img圆圈img缩略图”style=“显示:无”alt=“头像”>
<img src=”https://stackoverflow.com/questions/25390598/<?php echo$rowuser['profile_logo'];?>“class=“avatar img circle img缩略图”alt=“avatar”>
<h6>上载其他照片…&lt/h6>
<表单角色=“表单”id=“logoform”enctype=“多部分/表单数据”>
<输入id=“logo”name=“logo”type=“file”class=“text center block well sm”>
&lt/表格>
&lt/部门>
&lt/部门>

为了在jquery中使用formdata,必须设置正确的选项

$.ajax({
url:“/function/pro_pic_upload.php”,
类型:“POST”,
数据:postData,
processData:false,
contentType:false,
成功:函数(数据、文本状态、jqXHR){
$(“#pro#pix img”).last().show();
$(“#pro#pix img”).first().hide();
$(“#pro#pix h6”)。文本(数据);
},
错误:函数(jqXHR、textStatus、errorshown){
//如果失败
}
});

.ajax参考

processData(默认值:true)

类型:布尔型

默认情况下,传入的数据
将数据选项作为对象(从技术上讲,是除
字符串)将被处理并转换为查询字符串
默认内容类型“application/x-www-form-urlencoded”。如果
如果要发送DOMDocument或其他未处理的数据,请设置
选项为false

发表评论