Archived
1
0

construct formdata manually

This commit is contained in:
Jeff Becker 2017-10-01 11:46:28 -04:00
parent b3d65dc5b9
commit 54c0821339
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

View File

@ -105,8 +105,21 @@ onready(function() {
elem.innerHTML += ".";
}
};
var data = new FormData();
data.append("message", document.getElementById("comment").value);
var inputs = form.getElementsByTagName("input");
for(var input : inputs)
{
if(input.files)
{
for (var file : input.files)
data.append(input.name, file, file.name);
}
else if(input.name)
data.append(input.name, input.value);
}
ajax.open(form.method, form.action+"/json");
ajax.send(new FormData(form));
ajax.send(data);
};
var elems = document.getElementsByClassName("postbutton");
if(elems && elems.length > 0 && elems[0]) {