初始运行后无法执行jquery post或ajax

I can't seem to make the code below work after an initial successful click. I tried both $.post and ajax to no avail. The initial click to delete any of the items work, but the succeeding clicks do not work

<script>    
$(document).ready(function(){
$('[id^="del"]').click(function(){
    var valname = $(this).attr('id').split('del_');
    /*$.post("delthis.php", {id: ""+valname[1]+""}, function(data) {
            $("#dynamic_section").html(data);
    });*/
    $("#dynamic_section").load('delthis.php', {"id":valname[1]} );
    return false;
  });
});
</script>

<body>

<div id='static_section'>This is the static section</div>
<div id='dynamic_section' style='border: 1px solid black;'>
<?php
// db connection here
$sql = mysql_query("SELECT * from test_table ORDER BY id");
while ($row = mysql_fetch_array($sql))
{
?>
<p><a href='#' id='del_<?php echo $row['id']; ?>'>Hello <?php echo $row['id']; ?></a></p>
<?php
} 
?>
</div>

This is the simple delthis.php file:

<?php
// db connection 
//$id = $_POST['id'];
$id = $_REQUEST['id'];

$sql = mysql_query("DELETE from test_table WHERE id = '$id'");

$sql = mysql_query("SELECT * from test_table ORDER BY id");
while ($row = mysql_fetch_array($sql))
   $html .= '<p><a href="#" id="del_' . $row['id'] . '">Hello ' . $row['id'] . '</a></p>';

echo $html;

?>

Appreciate any help/pointers. TIA!

The problem is that you replace all the content of the #dynamic_section so you have to "re-bind" the click event. Try this.

<script>    
$(document).ready(function(){
    function doPost(evt) {
        evt.preventDefault();
        var valname = $(this).attr('id').split('del_');
        $.post("delthis.php", {id: ""+valname[1]+""}, function(data) {
            $("#dynamic_section").html(data);
            $('[id^="del"]').click(doPost);
        });
    }

    $('[id^="del"]').click(doPost);
});
</script>

Good luck!

you need to assign the click function to your links once the dynamic_section is done loading

here's my approach.

<script>    

$(document).ready(function(){
  callback();
});

function callback(){
  $('[id^="del"]').click(function(){
   var valname = $(this).attr('id').split('del_');
   $("#dynamic_section").load('delthis.php', {"id":valname[1]}, function(){ callback() });
   return false;
  });

}
</script>

Tried this and worked as well:

 $('[id^="del"]').live('click', function(){

I wonder what the pros/cons of this versus the other solutions posted. Similar?

Thanks.