Can javascript POST without refresh?

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

    Can javascript POST without refresh?

    Hello-

    I have a website that uses a custom built webserver to serve the pages.
    (Please don't ask me why my boss had his own web server written). I am
    displaying a log of information that is an unknown number of rows. This is
    currently displayed in a table.

    The table is generated by some code that we had to write (thank you custom
    webserver) so that the webserver will parse HTML files and fill in the tags
    we created with some data before returning that to the browser, the HTML
    looks a lot like ASP or JSP using the <% %> tags to denote something to be
    filled in.

    Now all that works fine and dandy, but in order for this log of information
    to show the latest stuff, the page needs to refresh and tell the server to
    go get the list of log info and fill in the HTML with the info then return
    it to the browser. All this happens pretty quick, but like any site, the
    page blinks while it refreshes.

    Now my boss wants that page to update without refreshing (the blink annoys
    him apparently). At first I said that it couldn't be done, but he said that
    he didn't believe me. Thus I am forced to ask you guys.

    I know you can update fields like that using JavaScript. (I made a font tag
    with an id and a JavaScript function resets the nodeValue. This changes the
    text without refreshing the screen). But my problem now is that I need to
    POST to the server to get the information without the page refreshing
    (through JavaScript?). Is this even possible? I planned on getting the
    data back and document.write( ) it all to the page.

    Any ideas?

    Post note: He saw his router's webpage dynamically update in this fashion.


  • Csaba2000

    #2
    Re: Can javascript POST without refresh?

    Your boss is correct, though it will take some care
    to do properly. You can get some ideas from

    and


    Csaba Gabor from New York

    Please post back what route you use if you get it working
    nicely. I'd be especially curious to know if you can use the
    cookie route (though I would probably use an IFRAME
    in your place).

    "Troy" <troy@morpheus. No_SpAm.net> wrote in message news:xFDcb.3504 $Xy2.2439929085 @newssvr12.news .prodigy.com...[color=blue]
    > Hello-
    >
    > I have a website that uses a custom built webserver to serve the pages.
    > (Please don't ask me why my boss had his own web server written). I am
    > displaying a log of information that is an unknown number of rows. This is
    > currently displayed in a table.
    >
    > The table is generated by some code that we had to write (thank you custom
    > webserver) so that the webserver will parse HTML files and fill in the tags
    > we created with some data before returning that to the browser, the HTML
    > looks a lot like ASP or JSP using the <% %> tags to denote something to be
    > filled in.
    >
    > Now all that works fine and dandy, but in order for this log of information
    > to show the latest stuff, the page needs to refresh and tell the server to
    > go get the list of log info and fill in the HTML with the info then return
    > it to the browser. All this happens pretty quick, but like any site, the
    > page blinks while it refreshes.
    >
    > Now my boss wants that page to update without refreshing (the blink annoys
    > him apparently). At first I said that it couldn't be done, but he said that
    > he didn't believe me. Thus I am forced to ask you guys.
    >
    > I know you can update fields like that using JavaScript. (I made a font tag
    > with an id and a JavaScript function resets the nodeValue. This changes the
    > text without refreshing the screen). But my problem now is that I need to
    > POST to the server to get the information without the page refreshing
    > (through JavaScript?). Is this even possible? I planned on getting the
    > data back and document.write( ) it all to the page.
    >
    > Any ideas?
    >
    > Post note: He saw his router's webpage dynamically update in this fashion.[/color]



    Comment

    • Stephen

      #3
      Re: Can javascript POST without refresh?

      Troy wrote:[color=blue]
      > Hello-
      >
      > [...snip...]
      > Now all that works fine and dandy, but in order for this log of information
      > to show the latest stuff, the page needs to refresh and tell the server to
      > go get the list of log info and fill in the HTML with the info then return
      > it to the browser. All this happens pretty quick, but like any site, the
      > page blinks while it refreshes.
      >
      > Now my boss wants that page to update without refreshing (the blink annoys
      > him apparently). At first I said that it couldn't be done, but he said that
      > he didn't believe me. Thus I am forced to ask you guys.
      >
      > I know you can update fields like that using JavaScript. (I made a font tag
      > with an id and a JavaScript function resets the nodeValue. This changes the
      > text without refreshing the screen). But my problem now is that I need to
      > POST to the server to get the information without the page refreshing
      > (through JavaScript?). Is this even possible? I planned on getting the
      > data back and document.write( ) it all to the page.
      >[/color]

      Wouldn't use document.write( )...

      Take a look at


      or


      [color=blue]
      > Any ideas?
      >
      > Post note: He saw his router's webpage dynamically update in this fashion.
      >[/color]

      Do view-source when looking at the router's webpage to see how that does it.

      Good luck!
      Stephen

      Comment

      • Troy

        #4
        Re: Can javascript POST without refresh?

        "Csaba2000" <news@CsabaGabo r.com> wrote in message
        news:bkvd4n$45d @dispatch.conce ntric.net...
        (snip)
        [color=blue]
        > Please post back what route you use if you get it working
        > nicely. I'd be especially curious to know if you can use the
        > cookie route (though I would probably use an IFRAME
        > in your place).[/color]

        Hi!

        Sorry it took so long for me to post back but I used the IFRAME method in
        the links you gave me. Thanks!

        Here's what I did. I created an IFRAME which hit's the server and gets the
        data. Then I used our homemade parser (i.e. ASP or JSP) to dynamically
        create a javascript 2D array of the data that will be displayed in a table
        later. That array is sent to the parent's write_table function when the
        IFRAME's onload event occurs.

        The parent receives this array and uses the DOM functionality
        (createElement, getElementByTag Tye etc) to dynamically create a table and
        set the table attributes. This effectively let's the refresh happen in the
        background and the table is updated immediately without any flashing or
        blinking of any kind.

        Then, I got fancy and removed all the javascript from the main html file and
        loaded them from .js files because I will be using these a lot. No problem
        with mozilla/netscape, but IE stopped working. See my other post in this
        newsgroup about that problem. I have no idea how to solve it.

        But thanks for your help, it is greatly appreciated!

        troy


        Comment

        Working...