Please help. I am trying to send a form data( in temp) using jQuery ajax.
My code:
function post1(URL, PARAMS) {
var temp = document.createElement("form");
temp.setAttribute("id", "form");
temp.action = URL;
temp.method = "POST";
temp.encoding = "multipart/form-data";
temp.style.display = "none";
<%for(int i=0;i<noOfPage;i++){%>
for(var x in PARAMS) {
var opt=document.createElement("textarea");
opt.name=x;
opt.value=PARAMS[x];
temp.appendChild(opt);
}
<%}%>
document.body.appendChild(temp);
$.ajax({
type: "POST",
url: URL,
async:false,
cache: false,
processData:false,
contentType: false,
data: temp,
success: function(data){
alert(data);
disablePdfIcon();
}
});
}
I am not sure, how to POST the form data in temp variable.
Even data:(#form).serialize() doesn't help.
I get java.io.IOException: Content type is not multipart/form-data in that case.
Please suggest an idea. Thanks in advance.
ianywhere - it just seems to do the same thingnoOfPagetimes