我目前正在测试客户端的推特墙,当页面以javascript开头时我正在加载墙。是否有可能重新加载div或javascript而无需重新加载浏览器?
这是我的div
<div id="social-stream"></div>
用js
加载它$(document).ready(function($){
$('#social-stream').dcSocialStream({
feeds: {
twitter: {
id: '#%23hashtag',
thumb: true,
images:'medium',
},
},
rotate: {
delay: 0
},
twitterId: 'something',
control: false,
filter: false,
wall: true,
cache: false,
max: 'limit',
limit: 16,
});
});
答案 0 :(得分:6)
是的,您可以使用setInterval之类的,
$(document).ready(function ($) {
function socialStream() {
$('#social-stream').html('').dcSocialStream({
feeds: {
twitter: {
id: '#%23swiss',
thumb: true,
images: 'medium',
},
},
rotate: {
delay: 0
},
twitterId: 'swiss',
control: false,
filter: false,
wall: true,
cache: false,
max: 'limit',
limit: 16,
});
}
socialStream();// first time load
setInterval(function () {
socialStream(); // reload div after every 5 seconds
}, 5000); // 5 seconds interval
});
此外,您还可以使用clearInterval来停止重新加载/刷新您的推特数据
答案 1 :(得分:0)
var container = $('#social-stream');
$(document).ready(function($){
loadTweets();
setInterval(loadTweets,200);
});
function loadTweets(){
container.empty();
container.dcSocialStream({
feeds: {
twitter: {
id: '#%23swiss',
thumb: true,
images:'medium',
},
},
rotate: {
delay: 0
},
twitterId: 'swiss',
control: false,
filter: false,
wall: true,
cache: false,
max: 'limit',
limit: 16,
});
}