Remote include

Discussion in 'JavaScript' started by awesomehosting, Nov 9, 2008.

  1. #1
    Hi all

    I have the following in my code:

    script: function (input) { return "flightdb.php?input="+input},
    Code (markup):
    However I need the flightdb.php to sit on a different server so how would I insert it in the attached eg:

    http://www.mydomain.co.za/common/flightdb.php? (etc )

    Please assist....
     
    awesomehosting, Nov 9, 2008 IP
  2. rene7705

    rene7705 Peon

    Messages:
    233
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    have you tried:

    script: function (input) { return "http://www.mydomain.co.za/common/flightdb.php?input="+input},
     
    rene7705, Nov 10, 2008 IP
  3. awesomehosting

    awesomehosting Banned

    Messages:
    409
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    130
    #3
    tried that however I get an error ajax 404 error...
     
    awesomehosting, Nov 10, 2008 IP
  4. wayfarer07

    wayfarer07 Peon

    Messages:
    34
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    JavaScript isn't allowed to read information from a remote domain, due to the same origin policy.
     
    wayfarer07, Nov 10, 2008 IP
  5. happpy

    happpy Well-Known Member

    Messages:
    926
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    120
    #5
    you need a proxy script on your own server, which fetches these contents via php and serves them frmo your domain to the browser.

    very simple one without any error checking:

    <?
    $x=file_get_contents("http://www.mydomain.co.za/common/flightdb.php?input=$_GET[input]");
    echo $x;
    ?>

    put this code into a file called "flightdb.php" and put it on your server.
     
    happpy, Nov 10, 2008 IP
  6. awesomehosting

    awesomehosting Banned

    Messages:
    409
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    130
    #6
    hey Happy

    Tried that however it says Object required ?

    any ideas ?
     
    awesomehosting, Nov 10, 2008 IP
  7. awesomehosting

    awesomehosting Banned

    Messages:
    409
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    130
    #7
    here is the whole script in this function:

     
    awesomehosting, Nov 10, 2008 IP
  8. tonyrocks

    tonyrocks Active Member

    Messages:
    1,574
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    88
    #8
    I bet it is a policy issue on your hosting plan...maybe some kind of fopen restriction
     
    tonyrocks, Nov 10, 2008 IP
  9. happpy

    happpy Well-Known Member

    Messages:
    926
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    120
    #9
    you put this script in a single php file? :
    <?
    $x=file_get_contents("http://www.mydomain.co.za/common/flightdb.php?input=$_GET[input]");
    echo $x;
    ?>
    Code (markup):
    try this one just for testing, it should show a google-startpage...:

    <?
    $x=file_get_contents("http://google.com");
    echo $x;
    ?>
    Code (markup):
    if this one also throws the same error, your PHP is running in SAFE_MODE with URL_FOPEN wrappers turned off.
    try to allow URL_FOPEN stuff in your cpanel, if not working ask your host.
     
    happpy, Nov 10, 2008 IP
  10. tonyrocks

    tonyrocks Active Member

    Messages:
    1,574
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    88
    #10
    I had a problem with dotnetpark not letting me turn on URL_FOPEN wrappers...just like I said...Policy issues :(
     
    tonyrocks, Nov 10, 2008 IP
  11. awesomehosting

    awesomehosting Banned

    Messages:
    409
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    130
    #11
    Thank you for the input...

    Just so I have you right I create a file called flightdb.php and put the above code in and leave the original js as it is....I can access the page and it brings up the xml feed however it does not work it throws the error:

    here is the test page:

    http://www dot cheapfares dot co dot za/engine/booking_engine_table.htm

    The coee works the auto suggest for to and from fields
     
    awesomehosting, Nov 10, 2008 IP