Can javascript POST without refresh?

Discussion in 'Javascript' started by Troy, Sep 25, 2003.

  1. Troy

    Troy Guest

    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.
    Troy, Sep 25, 2003
    #1
    1. Advertising

  2. Troy

    Csaba2000 Guest

    Your boss is correct, though it will take some care
    to do properly. You can get some ideas from
    http://groups.google.com/groups?th=eb5f407da2a4bf5
    and
    http://groups.google.com/groups?th=32712214ea820f6d

    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" <_SpAm.net> wrote in message news:xFDcb.3504$...
    > 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, Sep 25, 2003
    #2
    1. Advertising

  3. Troy

    Stephen Guest

    Troy wrote:
    > 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.
    >


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

    Take a look at
    http://devedge.netscape.com/viewsource/2003/inner-browsing/

    or
    http://jibbering.com/2002/4/httprequest.html


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


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

    Good luck!
    Stephen
    Stephen, Sep 25, 2003
    #3
  4. Troy

    Troy Guest

    "Csaba2000" <> wrote in message
    news:bkvd4n$...
    (snip)

    > 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).


    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, getElementByTagTye 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
    Troy, Oct 1, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. brian lanning
    Replies:
    0
    Views:
    574
    brian lanning
    Jul 29, 2003
  2. john
    Replies:
    4
    Views:
    5,009
    Curt_C [MVP]
    Jan 30, 2004
  3. =?Utf-8?B?QWxla3NhbmRhciBBbmRqZWxrb3ZpYw==?=

    Refresh data grid control without (post back)

    =?Utf-8?B?QWxla3NhbmRhciBBbmRqZWxrb3ZpYw==?=, May 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,104
    mortb
    May 24, 2004
  4. Pkenty
    Replies:
    0
    Views:
    378
    Pkenty
    May 28, 2004
  5. Adam
    Replies:
    8
    Views:
    396
Loading...

Share This Page