Forum Moderators: open

Message Too Old, No Replies

Importing external site's code?

         

synotic

1:10 am on Mar 27, 2005 (gmt 0)

10+ Year Member



Is there a way that I can load the contents of a given URL and be returned the source code as a string, which I can work with?

Specifically I'm trying to update a page every minute or so with the output of a PHP file I made, I would like to be able to just do get the PHP file's output and the manipulate it as I want, on the page. Is this possible? Thanks :)

adni18

6:58 pm on Mar 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can retrieve URLs in PHP and Perl, but there are restrictions build in to javascript to stop you from retrieving source code from domains other than your own.

synotic

11:20 pm on Mar 27, 2005 (gmt 0)

10+ Year Member



Thanks for the reply.

That's actually precisely what I'm trying to do: I want to retrieve the output a local PHP file on the same domain. I just don't want to constantly reload the page. So.. how do I do that? :)

P.S. I have looked around but I haven't been able to find anything of use.

jollymcfats

11:26 pm on Mar 27, 2005 (gmt 0)

10+ Year Member



XMLHttpRequest will do the trick.

synotic

8:35 pm on Mar 30, 2005 (gmt 0)

10+ Year Member



XMLHttpRequest will do the trick.

Thanks for the suggestion; I thought that I might be able to use it, but I thought it might be overkill—I figured there was another, simpler function. After a little bit of messing around with some examples, I was able to get it to work. My page now updates every 30 seconds (or whenever I want) without having to reload the page. I'll have to play with this some more :)