I've created a custom MultipartFilter for a HttpServletRequest
using this example to upload any kind of files from the client to my DataBase.
The form is a multipart/form-data
form placed inside a modal, shown in other form :
<!-- MAIN FORM -->
<form:form>
<button // this button shows the modal
</form:form>
<!-- MODAL TO UPLOAD FILES -->
<div class="modal fade" id="myModal" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
<form action="documentoSubmit" method="post" id="documentoForm" enctype="multipart/form-data">
I can submit my form and find the filed and other fields correct via my custom Filter in two ways:
a) Button onchange
method and javascript
function:
<button type="button" class="btn btn-primary" onclick="validarDocumento()">
<spring:message code="guardar" />
</button>
function validarDocumento() {
// check if valid data
$("#myform").submit();
}
b) Input field (can be also a <button>
):
<input type="submit" class="btn btn-default" >
This is working correct, but my problem is the parent form, which contains the modal with the form is being reloaded , I need to catch result to update my view via AJAX
WITHOUT reloading the form.
Anything similar to this, but with my custom java Filter
being applied
$.post( "<%=session.getAttribute("URL_HOST")%>/my/url/documentoSubmit", {})
.done(function(data) {
// do stuff...
}
or
$("#myForm").submit().done(function (data){
// do stuff...
});
or
$("#myForm").submit(function (data){
// do stuff...
});