ajax returning php/javascript code

tango

New Member
I was playing around with AJAX.If I do \[code\]echo "helllo"\[/code\]in the PHP file it works fine.However, if I do something like\[code\]echo "<script language=Javascript> alert('hi');</script>";\[/code\]in the PHP file, the \[code\]alert()\[/code\] does not come up.Anyone know if I'm doing anything wrong?example:in my html file i've got this\[code\]<div id='something'> </div>\[/code\]and i want the response text from the php file be placed above:\[code\]if (req.status==200) { document.getElementById('something').innerHTML=req.responseText;}\[/code\]if i changed that to:\[code\]if (req.status==200) { document.getElementById('something').innerHTML="<?php echo 'hi';?>";}\[/code\]it works fine, the response text will be ---> hi
but if i do \[code\]echo "\"<?php echo 'hi';?>\"";\[/code\] in my php file,the response text will be ""i hope i was clear in explaining
 
Back
Top