469,323 Members | 1,575 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

remotely including php script output via javascript

I've got a simple php script that dumps some database info out that I would
like to make available to others for inclusion on their web pages.
Problem is some of them dont have access to PHP or CGI.

Would this be possible with javascript?
Jul 23 '05 #1
3 1272
Tony Rice wrote:
I've got a simple php script that dumps some database info out that I would
like to make available to others for inclusion on their web pages.
Problem is some of them dont have access to PHP or CGI.

Would this be possible with javascript?


<script type="text/javascript" src="URLToYourPHPScript.php"></script>

And have the PHP script output it as a script variable, and then the
client can read the variables.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #2
Randy Webb <hi************@aol.com> wrote:
Tony Rice wrote:
I've got a simple php script that dumps some database info out that I would
like to make available to others for inclusion on their web pages.
Problem is some of them dont have access to PHP or CGI.

Would this be possible with javascript?


<script type="text/javascript" src="URLToYourPHPScript.php"></script>

And have the PHP script output it as a script variable, and then the
client can read the variables.


Alternatively, if the data on which the script is based doesn't change
too frequently, you can save your server a little work by periodically
writing a static .js file using a cron job. Be sure to serve the
correct http headers with the .js file to indicate when the data will
expire so UAs are advised when to fetch a fresh copy.

On the other hand, since URLToYourPHPScript.php is likely to get
cached, if the data changes in real time and the client must always
receive the latest data, they should append some query string to the
url like "URLToYourPHPScript.php?t=<timeInMilliseconds> ". (The query
string itself isn't used by the PHP script, but it forces a fresh load
of the file.)

--
Ray Morgan
http://Fares-Fair.com/
Jul 23 '05 #3
Ray Morgan <-@Fares-Fair.com> wrote in
news:lj********************************@4ax.com:
Tony Rice wrote:
I've got a simple php script that dumps some database info out that
I would like to make available to others for inclusion on their web
pages. Problem is some of them dont have access to PHP or CGI.

Would this be possible with javascript?


<script type="text/javascript" src="URLToYourPHPScript.php"></script>

And have the PHP script output it as a script variable, and then the
client can read the variables.


Alternatively, if the data on which the script is based doesn't change
too frequently, you can save your server a little work by periodically
writing a static .js file using a cron job. Be sure to serve the
correct http headers with the .js file to indicate when the data will
expire so UAs are advised when to fetch a fresh copy.

On the other hand, since URLToYourPHPScript.php is likely to get
cached, if the data changes in real time and the client must always
receive the latest data, they should append some query string to the
url like "URLToYourPHPScript.php?t=<timeInMilliseconds> ". (The query
string itself isn't used by the PHP script, but it forces a fresh load
of the file.)


Thanks to both of you for the information. The last part is especially
useful because the PHP script in question outputs "this day in history"
information which is obviously time sensitive.
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Nick Messick | last post: by
1 post views Thread by misdst23 | last post: by
10 posts views Thread by Robert Huff | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.