這裏是我的功能:jQuery的阿賈克斯不工作
$(".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"
);
});
當我點擊的一切作品,但它不會改變.score_neutre
值(這是1,我希望它更改爲2)。
你正在檢索一個json響應並將其用作字符串。 – yoda 2009-12-17 15:43:46
Btw json看起來像這樣 {score:12}或{values:{score:12}},你可以分別訪問 data.score或data.values.score。如果你想使用json封裝php中的所有內容作爲關聯數組,然後使用json_encode($ array); – MindStalker 2009-12-17 20:04:26