Php .live和ajax的问题

Php .live和ajax的问题,php,jquery,mysql,ajax,Php,Jquery,Mysql,Ajax,我有以下代码: $(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=='

我有以下代码:

$(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>");
                    });
                }
            });
        }
    });
});
$(文档).ready(函数()
{
$(“.vote.vote1”)。单击(函数()
{
var id=$(this.attr(“id”);
var name=$(this.attr(“name”);
var dataString='id='+id;
var parent=$(这是);
如果(名称=='mod_up')
{
$(this.fadeIn(200.html)(“”);
$.ajax({
类型:“POST”,
url:“mod_up_vote.php”,
数据类型:“xml”,
数据:dataString,
cache:false,
成功:函数(xml)
{
//$(“#mod pregunta”).html(html);
//$(“#mod respuesta”).html(html);
//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="up" class="vote1" id="<?php echo $id_pregunta."-".$id_respuesta; ?>-1" name="mod_up">Accept</a>

但是如果我在Accept中再单击一次,它的链接只显示gif(),不更新数据库,也不显示新的问题和答案


我必须如何使用.live()?或.delegate()?或者我需要什么?

使用
jQuery
live
而不是
单击

$(".vote, .vote1").live('click', function(){

.......
......


});

我更喜欢。代表。下面是一篇关于.delegate和.live的有趣文章:

以下是您需要做的事情:

$(document).ready(function() 
{
    $(document).delegate('.vote, .vote1', 'click', function()
    {
        //code
    });
});

我做了,并且绑定了。$(document).ready(function(){$(“.vote.vote1”).live(function(){{{var id=$(this.attr(“id”);var name=$(this.attr(“name”)…和…如果我第一次被重定向到家中时单击它,这将不起作用。不知道为什么。如果我更改了,我会投票,因为你在这里帮助了太多@Shankar和其他帖子。但有一件事,在官方文档中我看到了:$('.clickme').live('click',function(){谢谢@Jorge我实际上错过了活动类型
点击
这是
直播
方法的第一个参数。这很匆忙:)我写了一个有很多o的大LoL。但是有人会标记它,我可怜的19枚硬币会被扔掉。真的谢谢。(爱你)