Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Call and implement PHP+javascript code by using ajax

    Hi

    I have Mixed Code php + javascript Inside php file . I called the code inside this file by ajax .

    Example of the php code

    PHP Code:
    echo "<script type='text/javascript'>
      alert('Hello')
    </script>"

    The problem is that PHP code is executed, but the JavaScript code is not executed .

    Is there a solution for the implementation the two codes PHP + JS using ajax request

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    Executing embedded Javascript using Ajax requires the use of eval() ... which is mostly deprecated. Normally you should execute the required Javascript functions directly from your "main" document (the document which starts the Ajax request in the first place).

    But if you REALLY need to do that:
    Code:
    eval(' ' + xmlhttp.responseText + ' ');


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •