Calling a jQuery function from within an ajax-loaded div
I'm loading a div using this .ajax function:
$.ajax({
type: "GET",
contentType: "html",
url: url,
async: true,
success: function (conf) { $("#user_list_view").html( conf );}
});
<div id="user_list_view">
</div>
In that url that's being loaded I have this:
<script type="text/javascript">
$(document).ready(function() {
$('#user_list th').hover( function () {
alert("test test");
});
});
</script>
<table id="user_list">
........
........
........
</table>
But this simple jQuery function doesn't work. Why not? If I type the url for
this page directly then the function does work. How do you get a jQuery
function to work from a div loaded by ajax? When I look at the loaded page in Firebug, the script doesn't even show. What gives? Thanks.