Hey guys, I have a weird problem. I have an update system that refreshes data on a time interval. It works well in all browsers except internet explorer 8. The problem is that once it loads the data, it does not matter if the data updates further, it will not update the data visually until the internet history is cleared. I am not using any cookies server-side...Anyone ever encounter something like this?
Here is my javascript, thanks for any assistance in advance
function prepare(response) {
var d = new Date();
count++;
d.setTime(response.time*1000);
var mytime = d.getHours()+':'+d.getMinutes()+':'+d.getSeconds();
var string = '<li class="shoutbox-list" id="list-'+count+'">'
+ '<span class="shoutbox-list-nick"><a href="statistics.php?user='+response.user+'">'+response.user+'</a></span>'
+ ' <span class="date">'+mytime+'</span><br>'
+ '<span class="msg">'+response.message+'</span>'
+'</li>';
return string;
}
function refresh() {
$.getJSON(files+"shoutbox.php?action=view&time="+lastTime+"&topic_id="+topic_id, function(json) {
if(json.length) {
for(i=0; i < json.length; i++) {
$('#daddy-shoutbox-list').prepend(prepare(json[i]));
$('#list-' + count).fadeIn(1500);
}
var j = i-1;
lastTime = json[j].time;
}
//alert(lastTime);
});
timeoutID = setTimeout(refresh, 3000);
}
$(document).r开发者_Python百科eady(function() {
var options = {
dataType: 'json',
beforeSubmit: validate,
success: function(response, status){
if (response.error=='success'){
success(response, status);
}
else {
$.prompt(response.error);
}
}
};
$('#daddy-shoutbox-form').ajaxForm(options);
timeoutID = setTimeout(refresh, 100);
});
You should probably check your cache control on the server, this seem to in cause here. You can probably add a "no-cache" http header to your result.
This sounds like a caching issue. Try appending a random string to the URL to ensure that it gets changed.
var url = 'example.php?foo=bar&r=' + Math.random();
精彩评论