function sendForm(){
var oOutput = documeNT.getElemeNTById(“output”);
var oData = new FormData(documeNT.forms.namedItem(“fileinfo”));
oData.append(“CustomField”, “this is some extra data”);
var oReq = new XMLHttpRequest();
oReq.open(“poSt”, “stash.PHP”, true);
oReq.onload = function(oEveNT) {
if (oReq.status == 200) {
oOutput.innerHtML = “Uploaded ! ”;
}else{oOutput.innerHtML = “Error“ + oReq.status + “occurred uploading your file.”;}};
oReq.send(oData);
}
var fd = new FormData(documeNT.getElemeNTById(“fileinfo”));
fd.append(“CustomField”, “this is some extra data”);
$.ajax({
url: “stash.PHP”,
type: “poSt”,
data: fd,
ProCessData: false,
// 告诉jQuery不要去处理发送的数据
coNTeNTtype: false
// 告诉jQuery不要去设置CoNTeNT-type请求头});
原文链接:https://www.f2er.com/note/422764.html