EchoFool Posted May 28, 2012 Share Posted May 28, 2012 Hey I have a function which calls a php file - that php has a JS alert function call but it doesn't execute, so im a bit confused... MY function is: function call_file(file,div_id){ var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById(div_id).innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET",file,true); xmlhttp.send(); } call_file('test.php?u=name','div_id_test'); test.php: <script>alert('test'); //this doesn't work </script> <?php $user = $_GET['u']; echo $_GET['ud']; // this works ?> Why doesn't the alert occur ? And how do i solve it ? Quote Link to comment https://forums.phpfreaks.com/topic/263244-alert-function-doesnt-execute-on-request/ Share on other sites More sharing options...
requinix Posted May 28, 2012 Share Posted May 28, 2012 Quote Link to comment https://forums.phpfreaks.com/topic/263244-alert-function-doesnt-execute-on-request/#findComment-1349109 Share on other sites More sharing options...
EchoFool Posted May 28, 2012 Author Share Posted May 28, 2012 how come it does't execute script blocks? Seems a bit strange =/ Quote Link to comment https://forums.phpfreaks.com/topic/263244-alert-function-doesnt-execute-on-request/#findComment-1349110 Share on other sites More sharing options...
requinix Posted May 28, 2012 Share Posted May 28, 2012 More secure. It's not because the stuff came from an AJAX call but how it gets added to the document. Quote Link to comment https://forums.phpfreaks.com/topic/263244-alert-function-doesnt-execute-on-request/#findComment-1349116 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.