JQuery: olamaz yeniden güncelleme bağlantıları (I JQuery yeniyim)

0 Cevap php

I'm new to Jquery and I'm getting crazy to reupdate in ajax a code containing urls!! It works the first time, but the link does not work any longer after ajax response rewrites html.

Benim kod aşağıda bulabilirsiniz.

İlk HTML biçimlendirme (Görüntüle)

<head>  
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  <script type="text/javascript">  
  $(document).ready(function() { 
    $("a[class=unselected_quid], a[class=quid_selected]").click(function(){
        var url = $(this).attr("name");
        alert(url);
        $.ajax({
            url: "index.php", 
            type: "POST",  
            data: url,
            dataType: "html",
            success: function(msg) {    
                $("#result").html(msg);  
            },
            error: function(){
                alert("error!!!");
            } 
        });
    });
  });
</script>  
</head> 

<?php // set url strings in php
  $url = "component=Training&ctrl=JQueryTraining&task=ajaxLinkResponse&data=1";
  $url2 = "component=Training&ctrl=JQueryTraining&task=ajaxLinkResponse&data=2";
?>

<body>  
  <div id="result"><br>
    <a name='<?echo $url?>' href='javascript:void(0)' title='uno' class='selected_quid'>link a</a> <br>
    <a name='<?echo $url2?>' href='javascript:void(0)' title='due' class='unselected_quid'>link b</a><br>
  </div>  
</body>

Daha sonra PHP (Kontrol)

public function ajaxLinkResponse(){
  $url = "component=Training&ctrl=JQueryTraining&task=ajaxLinkResponse&data=1";
  $url2 = "component=Training&ctrl=JQueryTraining&task=ajaxLinkResponse&data=2";

  $code = "<a name='{<?$url?>}' href='javascript:void(0)' title='uno' class='selected_quid'>link a</a> 
  <a name='{<?$url2?>}' href='javascript:void(0)' title='due' class='unselected_quid'>link b</a>";  

  echo($code);
}

0 Cevap