【发布时间】:2011-09-05 21:40:17
【问题描述】:
我有这个代码:
$(document).ready(function()
{
$(".vote, .vote1").click(function()
{
var id = $(this).attr("id");
var name = $(this).attr("name");
var dataString = 'id='+ id ;
var parent = $(this);
if(name=='mod_up')
{
$(this).fadeIn(200).html('<img src="dot.gif" align="absmiddle">');
$.ajax({
type: "POST",
url: "mod_up_vote.php",
dataType: "xml",
data: dataString,
cache: false,
success: function(xml)
{
//$("#mod-pregunta").html(html);
//$("#mod-respuesta").html(html);
//parent.html(html);
$(xml).find('pregunta').each(function()
{
var id = $(this).attr('id');
var pregunta = $(this).find('preguntadato').text();
var respuesta = $(this).find('respuestadato').text();
var votoup = $(this).find('votoup').text();
var votodown = $(this).find('votodown').text();
var id_pregunta = $(this).find('id_pregunta').text();
var id_respuesta = $(this).find('id_respuesta').text();
$("#mod-pregunta").html(pregunta);
$("#mod-respuesta").html(respuesta);
$(".vote1").html("<a href=\"\" title=\""+ id_pregunta + "-"+ id_respuesta + "-1\" class=\"vote1\" id=\""+ id_pregunta + "-"+ id_respuesta + "-1\" name=\"mod_up\">Aceptar</a>");
});
}
});
}
});
});
通过此链接,它会更新数据库并显示新的问题和答案。
<a href="" title="up" class="vote1" id="<?php echo $id_pregunta."-".$id_respuesta; ?>-1" name="mod_up">Accept</a>
但是如果我再点击一次Accept的链接只显示gif()并且不更新数据库也不显示新的问题和答案。
我必须如何使用 .live()?还是.delegate()?或者我需要什么?
【问题讨论】: