开发者

jquery load() function working in Firefox but not in Chrome

jquery noob trying to dynamically update a div (#allimages) with new html dynamically created by a PHP script (hpimages.php). Seems like load() would be the thing, and I found a nice function on doing the updating here. Here's the code I'开发者_运维问答m using:

$.ajaxSetup({ cache: false });

$("#allimages").load("hpimages.php");
var refreshId = setInterval(function() {
$("#allimages").load('hpimages.php?randval='+ Math.random());
}, 1000);

It works great in Firefox ... keeps reloading behind the scenes so that when there is new content, it appears on the page. However, it behaves differently in Chrome: #allimages gets updated every second, but instead of REPLACING the existing html with the html coming from hpimages.php, it appends the new html to the old, so the page starts to grow huge with repeated content. Any ideas on how to fix in Chrome?


A dirty work around would be to empty the div first.

$("#allimages").html("").load( //...

I would also break down your page to something testable and report a bug. You may find that you messed it up when you are reducing the code down.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜