ajax 上传图片
<divclass="add_pic"><formname="add_pic"method="post"enctype="multipart/form-data"id="...
<div class="add_pic">
<form name="add_pic" method="post" enctype="multipart/form-data" id="add_pic">
<img src="/static/home/images/user/add_pic.gif">
<input type="file" name="Filedata" id="upload">
<input type="hidden" name="id" value="{$id}">
</form>
</div>
$("#upload").change(function() {
var formData = new FormData($("#add_pic"));
$.ajax({
url: "/user/operate/upload",
type: "post",
data: formData,
success: function(data) {
if (data.status == true) {
} else {
alert(data.errmsg);
}
}
});
});
结果 报错
TypeError: Argument 1 of FormData.constructor does not implement interface HTMLFormElement.
怎么解决 展开
<form name="add_pic" method="post" enctype="multipart/form-data" id="add_pic">
<img src="/static/home/images/user/add_pic.gif">
<input type="file" name="Filedata" id="upload">
<input type="hidden" name="id" value="{$id}">
</form>
</div>
$("#upload").change(function() {
var formData = new FormData($("#add_pic"));
$.ajax({
url: "/user/operate/upload",
type: "post",
data: formData,
success: function(data) {
if (data.status == true) {
} else {
alert(data.errmsg);
}
}
});
});
结果 报错
TypeError: Argument 1 of FormData.constructor does not implement interface HTMLFormElement.
怎么解决 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询