Benim Ajax fonksiyonu işe almak için doğru sözdizimi

0 Cevap php

The following code will not do what I hoped, that is run the Ajax function when the div ="dist" li created by the PHP code's is clicked.

Rehberlik lütfen.

<?php
  // ...
  $result = mysql_query($sql);
  echo "<div class=\"dist\">";
  echo "<ul>";

  while ($row = mysql_fetch_array($result)) {
      echo "<li><a href=\"devplan.php?search-n=" . $row['NAME'] .
           "&" . rawurlencode($row['PLAN']) . "\"" . ">" . 
           $row['PLAN'] . "</a></li>";
  };

  echo "</ul>";
  echo "</div>";
?>

<script type="text/javascript">
// Code to fill center panels with data
urlquery = location.search;
urlparts = urlquery.split('&');
urlplan  = urlparts[1];

$(document).ready(function() {
    $('.dist a').click(function() {
        $.ajax({
            url: 'php/dpdetails.php?q='+urlplan,
            success: function (data) {
               $('#Pinfo').html(data);
            }
        });
    });   
});
</script>

0 Cevap