我的页面上有三个div,每个div都是使用JQuery自动刷新的,这里是HTML:
<div id="photo">
<?php require("image.php"); ?>
</div>
<div id="right-bar">
<div id="facebook"> <?php require("graph.php"); ?></div>
</div>
<div id="bottom-bar">
<?php require("twitter.php"); ?>
</div>
这是JQuery:
var imagecacheData;
var imagedata = $('#photo').html();
var imageauto_refresh = setInterval(
function ()
{
$.ajax({
url: 'image.php',
type: 'POST',
data: imagedata,
cache: false,
dataType: 'html',
success: function(imagedata) {
if (imagedata !== imagecacheData){
//data has changed (or it's the first call), save new cache data and update div
imagecacheData = imagedata;
$('#photo').fadeOut("slow").html(imagedata).fadeIn("slow");
}
}
})
}, 60000); // check every minute
var cacheData;
var data = $('#facebook').html();
var auto_refresh = setInterval(
function ()
{
$.ajax({
url: 'graph.php',
type: 'POST',
data: data,
dataType: 'html',
success: function(data) {
if (data !== cacheData){
//data has changed (or it's the first call), save new cache data and update div
cacheData = data;
$('#facebook').fadeOut("slow").html(data).fadeIn("slow");
}
}
})
}, 30000); // check every 30 seconds
var twittercacheData;
var twitterdata = $('#bottom-bar').html();
var twitterauto_refresh = setInterval(
function ()
{
$.ajax({
url: 'twitter.php',
type: 'POST',
data: twitterdata,
dataType: 'html',
success: function(twitterdata) {
if (twitterdata !== twittercacheData){
//data has changed (or it's the first call), save new cache data and update div
twittercacheData = twitterdata;
$('#bottom-bar').fadeOut("slow").html(twitterdata).fadeIn("slow");
}
}
})
}, 60000); // check every minute - reasonable considering time it takes 5 tweets to scroll across
正如你所看到的,所有这些都是相同的东西,但twitter部分根本不会自动刷新。
另外,正如你所看到的那样,如果响应确实不同,我试图只让页面进行淡出/淡入但是它似乎仍然在做 - 有关为什么会这样做的任何想法?
提前感谢您的帮助
答案 0 :(得分:0)
原来问题是facebook没有登录。
一旦完成,它就被修复了。