javascript - Appending script with document.write synchronous -


i've encountered problem when appending script html. here sample code:

<script>$('body').append("<script type=\"text\/javascript\" src=\"http:\/\/localtest\/test.php\"><\/script>");</script> 

test.php source

<?php sleep(1); ?> document.write('<div></div>'); 

html inside append function can html, not necessarly script. works unless got html mentioned in example.

result

js code test.php not executed because it's blocked browser (i'm using ff): "a call document.write() asynchronously-loaded external script ignored."

i'm not able modify test.php content, it's loaded external server.

wy executed async? how force sync execution?

i think must use

$(window).ready(function() {      //put code here }); 

berfore appending.

so, complete code this

<script type="text/javascript">     $(window).ready(function() {          $('body').append("<script type=\"text\/javascript\" src=\"http:\/\/localtest\/test.php\"><\/script>");     }); </script> 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -