My form details are below:
<form id="CreateAttachmentForm" method="post" enctype="multipart/form-data" action="../../uploadFile" >
My file is defined as below:
<input type="file" id="fileupload1" name="fileupload1" accept="image/*,application/pdf" "/>
My custom button related code is below:
<contact:contactbutton
id="printButton"
style="position:relative; width:90px; top:27px; height:30px; left:160px;"
textTop="7px"
defaultButton="false"
tabindex=""
accesskey="C"
onClickEx="createAttachmentRequest();"
onfocus="if(event.altKey){click();}">
<u>C</u>reate
</contact:contactbutton>
I have the following function which is called upon clicking a custom button:
function createAttachmentRequest(){
alert("ONE");
$("#CreateAttachmentForm").trigger("submit", function() {
var formData = new FormData($(this)[0]);
alert("TWO");
$.ajax({
url: 'http://HDDT0214:8080/pqawdTestWebApp/uploadFile',
type: 'POST',
data: formData,
async: false,
success: function (data) {
alert("test");
alert(data)
},
cache: false,
contentType: false,
processData: false
});
return false;
});
The above Jquery code is calling my rest service successfully and the response is also returned by the rest service. Surprisingly the success function is not getting invoked/called even there is response from rest service. Is there something wrong with my code?