Here is a part of my JSP file where I have a problem :
<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>
And here is my jQuery file :
$(document).ready(function(){
$(".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){
alert(result)
// this is the line where i am having a problem
$(this).parent().parent().siblings().find(".nbrAdore").html(result)
}
})
})
})
Now what I am trying to achieve is that when I click my input ( button ) with class "adore2", the number of likes ( in span with class "nbrAdore" ) has to increment in my database.
I used alert to see if everything is fine just like any begginer and I will explain by an example.
If number of likes is 14, my value ( var value ) is fine, I get it, my alert shows 14, and my alert(result) shows 15 which means that the treatement in my controller is done correctly, but I can't see this in my view, I believe my problem is here and I dont know how to solve it :
$(this).parent().parent().siblings().find(".nbrAdore").html(result)