ajax returning php/javascript code -


I was playing with AJAX.

If I "helllo" in the PHP file

    

However, if I do something like this

  echo "& lt; script language = javascript & gt; alert ('hi'); ";  

In the PHP file, alert () does not occur.

Does anybody know that I am doing something wrong?

Example:

I have found this in my HTML file

   

And I should put the response text above the php file:

  if (req.status == 200) {document.getElementById ('some') InnerHTML = req.responseText }  

If I changed it:

  if (req.status == 200) {document.getElementById ('something'). InnerHTML = "& lt ;? php echo 'hi';? & Gt;"; }  

This works fine, the feedback text will be ---> hi
but if I echo "\" & lt ;? Php echo 'hi' ;; & Gt; \ ""; In my php file, the response text will be "

, I hope I explain

and the script will be evaluated.

  $ ("#include"). Load ("request.php");  

Maybe jQuery uses eval () too, so it is not much safer, but until load () only works on that domain, you should have control over those things A Or can be.

However, its use is easy, because you have not purses themselves their own pieces of script :)


Comments