i don't know if i asked the right question but anyway that is my problem : i followed a tutorial showing how to use ajax with Java ee and i made a simple example and it worked, but i tried to apply what i learned in my project and it didnt work, here is my jsp file :
<div class="aimerSection">
<div class="aime">
<form>
<input type="hidden" class="adore1" name="aime" value="${post.id}">
<input type="button" class="adore2" value="J'aime">
</form>
</div>
<c:if test="${ post.adore == 0 || post.adore == 1 }">
<div class="nbreAimes"><p><span class="nbrAdore">${ post.adore }</span> personne aime ça</p></div>
</c:if>
<c:if test="${ post.adore != 0 && post.adore != 1 }">
<div class="nbreAimes"><p><span class="nbrAdore">${ post.adore }</span> personnes aiment ça</p></div>
</c:if>
</div>
What i wanted is to get the value in the hidden input by clicking on my button( input button) so here is my jquery file :
$(".adore2").click(function(){
var aime = $(this).parent().find(".adore1").val()
var value=$(this).parent().parent().siblings().find(".nbrAdore").text()
alert(value)
$.ajax({
type:"POST",
data: {aime:aime},
url:"acceuilServlet",
success:function(result){
$(this).parent().parent().siblings().find(".nbrAdore").html(result)
}
})
})
And i wanted to see the result in the console ( as a test ) so here is a part of my Controller ( doPost method ) but i am getting any response.
resp.setContentType("text/plain");
int aime = Integer.parseInt(req.getParameter("aime"));
aime++;
System.out.println("hello "+aime);
Any help would be much appreciated.