0

I use XMLHttpRequest to dynamically change the content of a page:

if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("txtHint").innerHTML = this.responseText;
}
};
xmlhttp.open("GET","jeudip.php",true);
xmlhttp.send();

jeudip.php return html code (a list of image + javascript): here is a sample of what it return:

<p class="col1">nice picture1 <a id="exemple2" href="http://toto.fr/plat/spe1.jpg"><img width="60" alt="exemple2"     src="http://toto.fr/plat/spe1.jpg"></a></p>
<p class="col1">nice picture2 <a id="exemple2" href="http://toto.fr/plat/spe2.jpg"><img width="60" alt="exemple2"     src="http://toto.fr/plat/spe2.jpg"></a></p>
...

exemple2 is javascipt stuff that allow to make the image bigger (like facebook) but when the html + javascript code is returned by XMLHttpRequest, if I click on the picture, it didn't call the javascipt and just go to the picture (in the exemple http://toto.fr/plat/spe1.jpg). If call in the browser directly jeudip.php, the javascript work..

I hope I am clear about my problem as my english is not very good. thanks for any help.

maximephan
  • 43
  • 3
  • Ah, I think I misunderstood your question. So what code do you run to make the image bigger? You need to initialize that code after your Ajax call loads the images above. If you are inserting JavaScript along with the html, than that is the issue. – epascarello Dec 15 '16 at 14:02
  • hello, yes I inserting javascript along with html, how can I initialize the code after ajax call? – maximephan Dec 15 '16 at 14:45

0 Answers0