Can javascript POST without refresh?

T

Troy

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

Stephen

Troy said:
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
 
T

Troy

(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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top