here's my function:
$(".home .up_0").click(function() {
$.post("includes/vote.php",
{truc : $(this).attr("id")},
function(data) {
if(data==1) {
$(this).parents('.home').find('.score_neutre').append(
$(this).parents('.home').find('.score_neutre').val()+1
);
} else {
alert("Error !");
}
},
"json"
);
});
When I click everything works but it doesn't change the .score_neutre
value (which is 1 and I want it to change to 2).
You need to test (data.score==1) not data
"score" being the associated array name for the json data you sent in.
What does your json response look like? You can't compare it like this with a number.
Additionally you are using append
which most likely is wrong. I guess want you really wanted to do is
var ele = $(this).parents('.home').find('.score_neutre');
ele.val(ele.val()+1);