不发送给任何东西。当我试图在表单数据上显示结果时,它看起来是空的。
我的表格:
<form id="uploadform1236-1" method="POST" enctype="multipart/form-data" onsubmit="uploadprove('uploadform1236-1', event, 'post.php?action=uploadprove');">
<input name="picture" id="file-upload1236-1" class="" type="file">
<input name="testx" id="xxx1" class="" value="test1236" type="text">
<button id="uploadbutton1236-1" class="btn btn-primary btn-sm" type="submit">ttt</button>
</form>
使用Javascript:
function uploadprove(id, e, url) {
e.preventDefault();
var uploadform = $('#' + id)[0];
var formData = new FormData(document.getElementById(id)); //also tried to put uploadform variable here
alert(uploadform.toSource()); // results are ({0:{},1:{},2:{}}) It sees that 3 elements in form
alert(formData.toSource()); // results are ({})
$.ajax({
url: url,
type: "POST",
data: formData,
ContentType: false,
ProcessData: false,
success: function (data) {
alert(data);
}
})
}
答案 0 :(得分:0)
您的字段ContentType
和ProcessData
有误,是contentType
和processData
$.ajax({
url: url,
type: "POST",
data: formData,
contentType: false,
processData: false,
success: function (data) {
alert(data);
}
})