JavaScript -> PHP -> JavaScript

Discussion in 'Programming' started by stevo123, Jun 23, 2009.

  1. #1
    i have a problem with my site
    that calls a php file by INCLUDE() witch connect to my server and
    searches my database and return html by ECHO

    I want to change it to JavaScript code to call that php file
    and the php file to return JavaScript.

    any idea how i can do that?
     
    stevo123, Jun 23, 2009 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I read that it can be done if you add a header to the PHP file, so that it sends back Javascript instead of HTML. I'm not sure if this is right but here goes :D

    
    PHP file:
    <? Header('Content-Type: application/x-javascript')?>
    Javascript code
    
    Javascript to call the file:
    <script type="text/javascript" src="filename.php"></script>
    Code (markup):
     
    Cash Nebula, Jun 26, 2009 IP
  3. buchin

    buchin Active Member

    Messages:
    156
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    buchin, Jun 26, 2009 IP
  4. stevo123

    stevo123 Peon

    Messages:
    144
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    the thing is that the php file is not on the same server!
     
    stevo123, Jun 26, 2009 IP