【发布时间】:2011-07-30 09:24:38
【问题描述】:
我有以下 AJAX 函数来更新点击的投票。
$(function() {
$(".vote").click(function()
{
var id = $(this).attr("id");
var name = $(this).attr("name");
var dataString = 'id='+ id ;
var parent = $(this);
if (name=='up')
{
$(this).fadeIn(200).html('<img src="/content/voting/yes-enb.JPG" />');
$.ajax({
type: "POST",
url: "up_vote.php",
data: dataString,
cache: false,
success: function(html)
{
parent.html(html);
}
});
}
});
div/span html 代码如下
<span class="vote" id="53" name="up" style="text-decoration:none; color:none; margin:5px; ">
<img src="/content/voting/yes-enb.png" width=12 height=12 alt="">
<span style="text-decoration:none; color:none">'.$up.' </span></span>
所以上面的 AJAX 代码在用户每次点击投票按钮时递增计数器。但是在这种情况下,投票 img 以及投票计数都会被刷新。我想要的只是'.$up'。部分得到刷新。那只是投票部分。
知道如何做到这一点吗?
【问题讨论】: