如何让jquery与ajax一起工作? [重复]

This question already has an answer here:

Have the below code which loads a php page into a div, once this content is added the jquery on that php page doesnt seem to work. It only works if you open it directly (without ajax)

any ideas?

AJAX CODE

<script>
   $(document).ready (function() {
      $('#NavButton1').click(function(event) {
        $('#content').empty();
        $('#content').load('placeholder.php');
      })
    })
</script>

Jquery code on PHP page

<script>


$(document).ready(function() { 

    // call the tablesorter plugin 
    $('#myTable').tablesorter({ 
        // sort on the first column and third column, order asc 
        sortList: [[0,0],[2,0]] 
    }); 
}); 

</script>
</div>

document.ready is not triggered when you load your PHP.

But the right way to have a script run after you load external content would be to use a callback function:

$('#content').load('placeholder.php', function() { 
    // call the tablesorter plugin 
    $('#myTable').tablesorter({ 
        // sort on the first column and third column, order asc 
        sortList: [[0,0],[2,0]] 
    }); 
});