简体   繁体   中英

Error in javascript after load it with jquery.load

in my a.html i write this:

<script>
function Flike()
{ jQuery('#ft').load('like.php'); }
</script>

in the body of a.html i write

window.onload = Flike()

like.php is:

echo " <script> var e = document.createElement('script');
e.async = true;
e.src = '/facebook/like.js';
document.getElementById('ft').appendChild(e);
</script>
";}

Still now, All fine and works.

the problem is in like.js the script isn't work. this is like.js

I also tried without the document ready function... didn't work.

window.onload = Flike() is wrong

It should be

window.onload = Flike;

but if you are using jQuery, why are you not adding it

$(window).load(Flike)

And if you are just loading a script, why are you not using

$.getScript("/facebook/like.js");

Finally, if you are calling this after the page load, the document.ready event will not fire again for this new script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM