By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,798 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,798 IT Pros & Developers. It's quick & easy.

Can javascript POST without refresh?

P: n/a
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.
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <tr**@morpheus.No_SpAm.net> wrote in message news:xF***********************@newssvr12.news.prod igy.com...
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.


Jul 20 '05 #2

P: n/a
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/viewsour...nner-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

Jul 20 '05 #3

P: n/a
"Csaba2000" <ne**@CsabaGabor.com> wrote in message
news:bk********@dispatch.concentric.net...
(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
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.