I have a table of frequently updated information. This is presented using a container div with a div for each row, each row containing 10 divs.
我有一张经常更新的资料表。这是用容器div表示的,每个行都有一个div,每个行包含10 div。
I am using setInterval to call a an asmx webservice that returns some json formatted information.
我正在使用setInterval调用一个asmx webservice,它返回一些json格式的信息。
On the success callback I call $("#myContainer").empty();
on the container div and recreate the rows and 10 nested divs for each row's columns.
在成功回调中,我调用$(“#myContainer”).empty();在container div中,为每行的列重新创建行和10个嵌套div。
This page may be left to run for a whole day, so I am wary of updating the DOM like this as I have noticed that memory does rise for the browser over time (IE8).
这个页面可能要运行一整天,所以我对像这样更新DOM很谨慎,因为我注意到浏览器的内存会随着时间的推移而增加(IE8)。
The other approach I am considering is to add an id to the row div. When new results process each item of data, look for the corresponding row, if it exists overwrite the data in each div. If it doesn't exist (new data for example), append the row.
我正在考虑的另一种方法是向row div添加id。当新的结果处理每个数据项时,寻找对应的行,如果它存在,覆盖每个div中的数据。
What approaches have others used for this sort of long lived pseudo realtime information display.
还有哪些方法可以用于这种长时间的伪实时信息显示。
TIA
蒂雅
2 个解决方案
#1
5
In general, a very safe way to prevent memory leaks is to refrain from destroying and re-creating DOM elements. In situations such as yours, I always try to keep the initial DOM structure, and simply update the inner text of the elements when fresh data from AJAX requests is available.
通常,防止内存泄漏的一种非常安全的方法是避免破坏和重新创建DOM元素。在类似您的情况下,我总是尝试保持初始的DOM结构,并在AJAX请求提供新的数据时简单地更新元素的内部文本。
#2
1
Refresh the page once in a while.
偶尔刷新一下页面。
#1
5
In general, a very safe way to prevent memory leaks is to refrain from destroying and re-creating DOM elements. In situations such as yours, I always try to keep the initial DOM structure, and simply update the inner text of the elements when fresh data from AJAX requests is available.
通常,防止内存泄漏的一种非常安全的方法是避免破坏和重新创建DOM元素。在类似您的情况下,我总是尝试保持初始的DOM结构,并在AJAX请求提供新的数据时简单地更新元素的内部文本。
#2
1
Refresh the page once in a while.
偶尔刷新一下页面。