I have javaee
project. I want to send image file to my servlet via ajax.
Ajax not sending image file to my java class. But it is sending textarea value.
Here is my form
<form enctype="multipart/form-data" beanclass="ActionBean">
<input type="file" id="uploadFile" name="newAttachment"/>
<textarea name="name" id="name" rows="2" cols="30"></textarea>
<s:submit value="Edit" name="saveOfferInfo" onclick="return edit(this);" />
JavaScript function:
function edit(button) {
var form = button.form;
var params = $(form).serializeArray();
params.push({name: '_eventName', value: button.name});
$.post(form.action, params, function (data) {
alert("success");
});