Following jsp code works fine in the forntend with Form but I wanted to find out how to call the action using Jquery. In short I do not want to use action and directly invoke the same through jquery.
<form:form id="uploadCSVForm" modelAttribute="PeopleFileUpload" method="post" enctype="multipart/form-data" action="/admin/institutions/${mrceuser.person.institution.id}/uploadCsv">
<p>
<form:label for="fileData" path="fileData">File</form:label><br/>
<form:input path="fileData" type="file"/>
</p>
<p>
<input type="button" value="Save" onclick="InstitutionDialog.prepareForSubmit('#uploadCSVForm');" />
<input type="button" value="Cancel" onclick="InstitutionDialog.hide();return false;"/>
</p>
</form:form>
I have achieved the same using
ChangeDialog.noInputSubmit(ChangeDialog.InstitutionsProperty, "Uploaded CSV for " + jQuery('input#name').val(),
function () {jQuery('#uploadCSVForm').submit()});
Where ChangeDialog.noInputSubmit looks like this :
ChangeDialog.noInputSubmit = function (changeArea, message, callback) {
ChangeDialog.changeArea = changeArea.id;
var valueMap = ChangeDialog.getValueMap();
valueMap.description = message;
jQuery.ajax({
url:RootPath.getPath()+'/admin/changes/',
type:'POST',
data:valueMap,
success:callback,
error:ChangeDialog.handleError
});
return false;
};