Does anyone know how I can make document.write with a script tag block execution?
<script type="text/javascript">
var test = "bad";
document.write('<script type="text/javascript" src="js.php"><\/script>');
console.log(test);
</script>
Where js.php is
<?PHP sleep(1); echo "var test='good';"; ?>
console.log should output "good", but it outputs "bad". Of course, after a second, the var does change to "good", but I definitely need it to be blocking. Thanks!!
I kind of see whats happening. It looks like any document.write in the current script block actually gets written right after the current script block.