Problem making a script "see" an element loaded in Ajax
Hello,
I am coding a web page that displays an image that have the #zoom tag, i found a magnifying plugin and i want to load different images with the #zoom tag and make that plugin to "see" the actual image.
I have this code
- function ajax(color){
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("slide-left").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","img.php?color="+color,true);
xmlhttp.send();
}
</script>
The script for the plugin ( I know i have to change the .ready . i have tried with bind, and other things I've found on the internet, but it only got me more confused.)
- <script type="text/javascript">
jQuery(document).ready(function($){
$("#zoom").addpowerzoom({
defaultpower:3,
powerrange: [2, 10],
magnifiersize: [200, 200]
})
})
</script>
And the button
- <button type="button" onclick="ajax('orange')">Request 2</button>
I have researched, at first I thought bringing the script with the image at the ajax response would do it, but i have found that javascript isn't executed, and im a little bit confused. Now i think is easier to make the script to see an element brought by ajax but i dont know where to start.
could you help me?
Thank you