Including remote php scripts with Javascript

Discussion in 'PHP' started by aras, Aug 10, 2006.

  1. #1
    Hello

    I want to include remote php scripts with JS (because not all sites have php built in)

    I use document.write('<img src=www.xxx.com/do.php?bla>') etc. But sometimes i do not want to output images and still need to include remote php files. How can i do this (for ex: plain or formatted text/html output) for a remote php file?

    Thanks
     
    aras, Aug 10, 2006 IP
  2. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There are two possible solutions. Probably the easiest is frames, whereby the various sections of the site can come from different places. I have played around with this, even using CGI scripts to generate output

    <iframe width="100%" scrolling="no" src="http://www.SOMEWHERE.com/showcontent.php">
    </iframe>


    The other thought I have is to call a php scipt as if it were external javascript and have it write its output in javascript.
     
    clancey, Aug 10, 2006 IP
  3. aras

    aras Active Member

    Messages:
    533
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #3
    For the second option, lets say i call a x.php file as Javascript, how could be mysql queries sent from it. I can understand values can be printed with document.write however what about functions?
     
    aras, Aug 11, 2006 IP
  4. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #4
    This seems a strange way to do things. What exactly are you trying to build? Can you use AJAX? or just pull in a remote js file using <script> tags. The js file can be generated with php/mysql on the other site.
     
    mad4, Aug 11, 2006 IP
  5. Gordaen

    Gordaen Peon

    Messages:
    277
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Is this for an open source project? Otherwise, I can't see why you would be trying this? As mad4 hinted, Ajax is the best bet for what you are trying to do (as long as I am understanding you correctly).
     
    Gordaen, Aug 11, 2006 IP
  6. casper

    casper Guest

    Messages:
    181
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    <script src="http://www.yoursite.com/?bla=0&bla=1&bla2=2"></script>

    Just use parameters to send details to your server
     
    casper, Aug 12, 2006 IP
  7. aras

    aras Active Member

    Messages:
    533
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #7
    Its not something strange. Every server does not support PHP codes that my system needs to be linked to :)
     
    aras, Aug 12, 2006 IP