So, I tried this:
$.ajax({
url: 'cod.php',
type: 'POST',
dataType: 'html',
success: function(res){
$("#tests").html(res);
}
In my PHP, I have a foreach
loop that brings me all data from a MySQL query.
<?php
foreach ($var as $row){
echo "<span class='name'>$row</span>";
}
?>
The data provided by PHP are something like this:
<span class='click' id='name1'>Name1</span>
<span class='click' id='name2'>Name2</span>
The HTML shows correctly the PHP data, returned by Ajax.
e.g.: Name1
, Name2
..
But, the click
handler at the class: click
doesn't works.
$('.click'),click(function(){
alert('testing');
});
Please, how do I solve this?
Thank's a lot! ;)