I have a code like below:
$.get( "includes/ajax_ok.php", { edycja: "<?=$_GET[edycja]; ?>"} ,function( data ) {
$('#lista').html(data);
});
$("document.body").on('click', '#test' ,function(){
event.preventDefault();
alert("ok");
});
<body>
<div id="lista"></div>
</body>
For test purposes, ajax_ok.php file has only a code line:
<a href='' id='test'>x</a>
The problem is, when i click an anchor x the alert with ok message doesn't appear.
I have tried code like below with succeed so I think the reason is $.get() function but I have to do this with it.
$('#lista').html("<a href='' id='test'>x</a>");
$("document.body").on('click', '#test' ,function(){
event.preventDefault();
alert("ok");
});
Maybe someone had the same problem but has a solution?