Adetoro Lanre Adetoro Lanre - 4 months ago 17
jQuery Question

JavaScript not working in JQuery Load

I wan to display a code with JavaScript then load it using

jQuery
load.

Here is my codes :

<div class="noti"><span name="creator">::creator::</span></div>

<script type="text/javascript"> creators=document.getElementsByName('creator'); for(i=0;i<creators.length;i++){creator=document.getElementsByName('creator')[i].innerHTML; :userstats:d=ru,o=dl,s=1,l=50::if(creator=='%name%'){document.getElementsByName('avatar')[i].innerHTML='<a href="%urlprofile%"><img src="%urlpicture%" width="40" height="43" style="background: url(http://wapkaimage.com/400207/400207380_d4c2093a7f.PNG);" width: 40; height: 43;"/></a>';}:: :/userstats:}</script>


Then in another url, load with this :

<div class="title">NOTIFICATION</div><div id="noti">Loading notification...</div>
<script type="text/javascript"> $('#noti').load('/popup_0.xhtml .noti',function(data){$(this).find('.noti').css({"width":"96%","margin":"auto"}); }); </script>


The problem is the result of span name creator is not displayed in the JQuery load but it displays in the 1st
url
.

Answer

That because the changes made by your javascript doesn't affect source/original file popup_0.xhtml, but still affected just the DOM loaded in the browser, when the load() function get the code inside the source file.

Hope this helps.