Request Server Information Client Side

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

    #1

    Request Server Information Client Side

    Hi

    I am a bit of a novice with JS and this may seem like a completely
    stupid question, but i want to be able to update a bit of text on a
    page based on information from the server without reloading the page.

    The only way i can think of doing such a thing is having an active
    server page that returns an image, that is generated on the fly. As
    long as there is no caching on the client this in theory will allow
    the client to perform an action on the server and display an image
    generated on the fly as a result of this action without actually
    reloading the page, simply by requesting an image.

    My question is, can you do anything like this with straight forward
    text?

    Cheers

    Blu
  • Colin McKinnon

    #2
    Re: Request Server Information Client Side

    BluDog wrote:[color=blue]
    >
    > I am a bit of a novice with JS and this may seem like a completely
    > stupid question, but i want to be able to update a bit of text on a
    > page based on information from the server without reloading the page.
    >[/color]

    Add a (hidden) iframe, when you want to get the information from the server,
    change it's location to a server-side script with approriate query params.
    The script should return a page containing a javascript function which in
    turn sets the text in the main page e.g.

    <html>
    <body>
    <script>
    parent.document .getElementById ("changeMe").va lue
    ="this came from the server";
    </script>
    </body>
    </html>

    HTH

    C.

    Comment

    • BluDog

      #3
      Re: Request Server Information Client Side

      On Fri, 01 Oct 2004 11:36:31 +0100, Colin McKinnon
      <colin.deleteth is@andthis.mms3 .com> wrote:
      [color=blue]
      >BluDog wrote:[color=green]
      >>
      >> I am a bit of a novice with JS and this may seem like a completely
      >> stupid question, but i want to be able to update a bit of text on a
      >> page based on information from the server without reloading the page.
      >>[/color]
      >
      >Add a (hidden) iframe, when you want to get the information from the server,
      >change it's location to a server-side script with approriate query params.
      >The script should return a page containing a javascript function which in
      >turn sets the text in the main page e.g.
      >
      ><html>
      ><body>
      ><script>
      >parent.documen t.getElementByI d("changeMe").v alue
      > ="this came from the server";
      ></script>
      ></body>
      ></html>
      >
      >HTH
      >
      >C.[/color]

      Ideal, Thanks Colin!

      Comment

      • kaeli

        #4
        Re: Request Server Information Client Side

        In article <67aql0tce4v9dn k0el8f2runrsbnm 08ood@4ax.com>,
        news@nospam.blu dog.net enlightened us with...[color=blue]
        > Hi
        >
        > I am a bit of a novice with JS and this may seem like a completely
        > stupid question, but i want to be able to update a bit of text on a
        > page based on information from the server without reloading the page.
        >[/color]

        You can use an image or a dynamic script element that references any code on
        your server that returns the proper content type.

        I've got an example with Perl here that uses a dynamic script element.


        Someone (maybe Grant?) posted a real nice alternative that was more cross-
        browser using an image src attribute awhile back. Look in the archives.

        --
        --
        ~kaeli~
        If at first you don't succeed, skydiving is not for you.



        Comment

        Working...