I’m using this
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("picHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getpic.php?q="+str+"&t=" + Math.random(),true);
xmlhttp.send();
to pass in data and generate an undefined amount of pictures with the echo from PHP code in getpic.php
while($row = mysql_fetch_array($result)){
echo "<div id=" . $num . "><img src=QR/" . $row['img']".png></div>";
}
So these pictures do come out generated, however, now I’m trying to use
$("#img").click(function () {
alert("Hi");
});
but nothing gets alerted. The top function posts the stuff in the however i can’t seem to call inside that id? How can I call the div or the img inside the outer div?
If you’re generating content asynchronously,
$.click()won’t work unless you manually attach it to each new element. Try using$.live()instead:Be sure to check your
ids as well, and note that using integers for your id is not a good practice. If you wish to use the numerical id of the image as the id, preface it with some type of alpha-value, such as#image19.