Reputation: 3148
I have a web page which allows the user to carry out various operations that in turn modify the database. Also, this web application needs to keep track of various fields in database that keep changing with time. Is refreshing the page every few seconds the best possible way to implement this? For example, if there is a long list on the page requiring scrolling, it is hard to view the list since the page keeps resetting due to the refresh. I know, there are ways to retain the position of the scroll. But, could I use something more efficient?
Upvotes: 19
Views: 73402
Reputation: 27
if you want to autorefresh the whole page,use meta html tag in the page header.but it better to autoresh the specified part of the page using AJAX to avoid the elasticity of loading time
Upvotes: 1
Reputation: 1
I think that the following is a good solution with the refresh command in the header.
When you call the httpSuccess function try to use this:
server.httpSuccess("text/html","Refresh: 30\r\n");
Upvotes: 0
Reputation: 350
This task is very easy use following code in html header section
<head> <meta http-equiv="refresh" content="30" /> </head>
It will refresh your page after 30 seconds.
Upvotes: 7
Reputation: 1421
Place it under head tag
<meta http-equiv="refresh" content="5">
This will refresh page every after 5 seconds.
For other option refer link text
Upvotes: 48
Reputation: 2808
I think you need something similar to Reverse AJAX now popularly known as Comet. It is server pushing the data to the client instead of browser polling the data from the server/database. http://en.wikipedia.org/wiki/Comet_(programming) has a good introduction. There are already many frameworks (e.g. DWR, ICEFaces) that support this pattern.
Upvotes: 2
Reputation: 16369
Use AJAX with timer.Using this we can refresh the particular part in the page.
Upvotes: 8
Reputation: 10409
Without going into too much detail, in general you might want to consider generating your HTML dynamically, using Javascript, in an Ajax-style manner. It's considerably more challenging to do right, but it's the right way to go from a user-experience perspective.
Check out the Yahoo user-interface library for guidance and assistance -- it does make things a good deal easier than trying to do everything by hand.
Upvotes: 1
Reputation: 35117
That sounds like a functionality that would be better suited in a Flash or Silverlight application. Using an elaborate AJAX solution might be a bit more efficient than your but the reality is that web pages make a terrible medium for live content.
Upvotes: 0
Reputation: 14643
Short answer is NO. YOu can use ajax to update the necessary components. This reduces the load time and keeps your page from resetting.
Upvotes: 3