我正在尝试使用该方法live
,它最初按预期工作,但 ajax 'success' 回调在该函数的后续运行中无法正常运行。
$(function () {
$('.vote').live('click', function () {
url = '".base_url()."post/vote';
post_id = $(this).attr('id');
$.ajax({
url: url,
type: 'POST',
data: 'post_id=' + post_id,
success: function (msg) {
post = $('.num_vote' + post_id);
vote = $('.votes' + post_id);
$(vote).html(msg); // working only the first time
}
});
return false;
});
});