투표 시스템과 같은 Stackoverflow를 만들려고하고 있는데 약간의 문제가 있습니다.jQuery 투표 시스템에 대한 도움말. 문제 : html 투표 수를 업데이트하는 중
이<div id="c_<%=Html.Encode(Model.C.cID) %>" class="votes">
<img src="../../Content/gfx/Up.png" class="up" alt="" />
<span class="votecount"><%= Html.Encode(Model.C.VoteCount)%></span>
<img src="../../Content/gfx/Down.png" class="down" alt="" />
</div>
JQuery와 온 클릭은 다음과 같습니다 :
$(".up").click(function() {
var id = $(this).parent().attr("id").split("_");
if (id[0] == "c") {
//C Vote
//id[1] contains the id number.
$.post("/Vote/CUp", { id: id[1] }, function(data) {
$(this).parent().children(".votecount").html(data.voteCount);
},
"json"
);
} else {
//R Vote
$.post("/Vote/RUp", { id: id[1] }, function(data) {
$(this).parent().children(".votecount").html(data.voteCount);
},
"json"
);
};
});
내 문제가 당첨 기회를 업데이트하려고에있다
나는 그것에 유선 jQuery를 온 클릭 이벤트가 다음과 같은 HTML이있다. 방금 JSON 객체에 반환 된 값으로 보텀 스팬을 업데이트하는 방법을 알아낼 수 없습니다.
json으로 개체가 반환하는 데이터는,이 사용 경고 (데이터)
도움이 많이 감사를 확인했습니다.
은 .. 아아 기쁨 ... 각각 (". votecount")를 모두 다음 내용 .. 및 .prev을 그것을 시도하지하지만 응답에 감사드립니다 그럼에도 불구하고. –
@Jeremy -'$ (this) .siblings ('.votecount') .html (data.voteCount);'을 사용해 보셨습니까? – karim79
@ karim79. 오늘 그걸 시도 했어. 불운. $ (this)는 $ .post 함수 내에서 작동하지 않는 것으로 보입니다. 그런데 다시 jQuery를 이해할 수 없으므로 아마 틀릴 것입니다. –