I have a jsp
which contains a form
, I want to send this form
data to a servlet
with ajax
, and then in success
to get some data from servlet
and display it in my jsp
.
this is my form :
/WEB-INF/quiz.jsp
<form name="example-1" id="wrapped" action="Resultat" method="POST" >
//Inputs
<button type="submit" class="submit" id="calculer">Calculer mon résultat</button>
</form>
And this is the JavaScript :
/WEB-INF/inc/js/functions.js
$("#wrapped").submit(function(event){
event.preventDefault();
var form = $(this),
formData = new FormData(this),
url = form.attr('action');
$.ajax({
url : url,
type : 'POST',
data : formData,
success : function(data){
$("#resultat").html(data);
}
});
});
My question is : How can I get the values in my sevlet
to manipulate them ? and then how can I define that data attribute in the success in my sevlet
?