remotely including php script output via javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony Rice

    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?
  • Randy Webb

    #2
    Re: remotely including php script output via javascript

    Tony Rice wrote:
    [color=blue]
    > 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?[/color]

    <script type="text/javascript" src="URLToYourP HPScript.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.javas cript FAQ - http://jibbering.com/faq/

    Comment

    • Ray Morgan

      #3
      Re: remotely including php script output via javascript

      Randy Webb <hikksnotathome @aol.com> wrote:
      [color=blue]
      >Tony Rice wrote:
      >[color=green]
      >> 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?[/color]
      >
      ><script type="text/javascript" src="URLToYourP HPScript.php"></script>
      >
      >And have the PHP script output it as a script variable, and then the
      >client can read the variables.[/color]

      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 URLToYourPHPScr ipt.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 "URLToYourPHPSc ript.php?t=<tim eInMilliseconds >". (The query
      string itself isn't used by the PHP script, but it forces a fresh load
      of the file.)

      --
      Ray Morgan

      Comment

      • Tony Rice

        #4
        Re: remotely including php script output via javascript

        Ray Morgan <-@Fares-Fair.com> wrote in
        news:lj57c09aem ip6g58ohruaj176 n0lec08pa@4ax.c om:
        [color=blue][color=green]
        >>Tony Rice wrote:
        >>[color=darkred]
        >>> 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?[/color]
        >>
        >><script type="text/javascript" src="URLToYourP HPScript.php"></script>
        >>
        >>And have the PHP script output it as a script variable, and then the
        >>client can read the variables.[/color]
        >
        > 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 URLToYourPHPScr ipt.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 "URLToYourPHPSc ript.php?t=<tim eInMilliseconds >". (The query
        > string itself isn't used by the PHP script, but it forces a fresh load
        > of the file.)[/color]

        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.

        Comment

        Working...