auto refresh div content ...
4 posters
Page 1 of 1
auto refresh div content ...
I tested this code, but doesn't work correctly ...
- Code:
jQuery(document).ready(function() {
var refreshId = setInterval(function()
{
jQuery('.main).load('/ .main');
}, 20000);
jQuery.ajaxSetup({ cache: false });
});
It makes the .main div hidden.
Any ideas?
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: auto refresh div content ...
Try my code
or
- Code:
jQuery(document).ready(function() {
var refreshTime = 2000; // Time of reload
chacke_time = new Date(); // Get the date.
setTimeout(function(){
// your function here...
}, refreshTime);
console.log(chacke_time+ ' - Reload time is: ' +refreshTime+ ' sec.');
});
or
- Code:
$(document).ready(function(){
setInterval(function(){
cache_clear();
console.log(new Date()+' Refresh !! '+'x secound');
}, 10000);
});
function cache_clear(){
window.location.reload(1);
};
Re: auto refresh div content ...
Please read my post again. I ask about auto refresh a specific Div, not the all page.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: auto refresh div content ...
- Code:
$(document).ready(function(){
var time = 2000;
setInterval(function(){
cache_clear();
console.log(new Date()+' Refresh !! '+'x secound');
}, time);
});
function cache_clear(){
jQuery('.main).load('/ .main'); // Div of load and reload single div
};
Re: auto refresh div content ...
Still does not work properly...
I use this code to add the profile link to the Avatar system.
- Code:
$(document).ready(function(){$('tr td.tcr').each(function(){$(this).find('.lastpost-avatar img').wrap('<a href="'+$(this).find('span strong a').attr('href')+'">')})});
but, your code removes the link when reload the div.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: auto refresh div content ...
Hello,
You have a syntax error on your code...
Try this:
Best regards, Wagner
You have a syntax error on your code...
Try this:
- Code:
$(function(){
var m = $('.main'),
refresh = function(){
m.load('/ .main', function(){
console.log('A refresh was performed.');
});
};
window.setInterval(refresh, 20000);
});
Best regards, Wagner
Re: auto refresh div content ...
Still the same problem. It removes the Avatar profile-link when reload the div.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: auto refresh div content ...
Test here. Take a look on the Avatar link.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: auto refresh div content ...
This is why you just running one function every 10000 milliseconds, you need to update the both functions...
Try this code:
Remove these two Javascripts..
Try this code:
- Code:
$(function(){
var r = function(){
var m = $('.statused'),
refresh = function () {
m.load(location.href + ' .statused>*', function () {
console.log('A refresh was performed.')
})
};
$('tr td.tcr').each(function () {
$(this).find('.lastpost-avatar img').wrap('<a href="' + $(this).find('strong a').attr('href') + '">')
});
};
window.setInterval(r, 3000);
});
Remove these two Javascripts..
- Code:
$(document).ready(function () {
$('tr td.tcr').each(function () {
$(this).find('.lastpost-avatar img').wrap('<a href="' + $(this).find('strong a').attr('href') + '">')
})
});
- Code:
$(function () {
var m = $('.statused'),
refresh = function () {
m.load(location.href + ' .statused>*', function () {
console.log('A refresh was performed.')
})
};
window.setInterval(refresh, 10000)
});
Re: auto refresh div content ...
The Avatar link doesn't work now.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: auto refresh div content ...
Hello Ahmed,
First change the pathname in the load function to /forum, just / is equal to your forum homepage. Secondly add a callback function after the page has loaded to reapply the ava links.
Try the below :
First change the pathname in the load function to /forum, just / is equal to your forum homepage. Secondly add a callback function after the page has loaded to reapply the ava links.
Try the below :
- Code:
jQuery(document).ready(function() {
refreshId = setInterval(function() {
jQuery('.main').load('/forum .main', function() { $('tr td.tcr').each(function(){$(this).find('.lastpost-avatar img').wrap('<a href="'+$(this).find('span strong a').attr('href')+'">')}); });
}, 20000);
jQuery.ajaxSetup({ cache: false });
});
Re: auto refresh div content ...
Still doesn't work. See.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: auto refresh div content ...
This one .statused.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: auto refresh div content ...
That will not work correctly as it will replace every category with the first .statused's contents. It would be better to use .main:has(.statused) as that will only select the .main div which contains the forum content.
- Code:
jQuery(document).ready(function() {
refreshId = setInterval(function() {
jQuery('.main:has(.statused)').load('/forum .main:has(.statused)', function() { $('tr td.tcr').each(function(){$(this).find('.lastpost-avatar img').wrap('<a href="'+$(this).find('span strong a').attr('href')+'">')}); });
}, 20000);
jQuery.ajaxSetup({ cache: false });
});
Re: auto refresh div content ...
Well, it works in the main site.
But Can i load two ids with one load?
Like this: jQuery('Div').load('/ #Div1, #Div2'); ?
But Can i load two ids with one load?
Like this: jQuery('Div').load('/ #Div1, #Div2'); ?
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: auto refresh div content ...
No, it doesn't ...
for example this code:
The result.
for example this code:
- Code:
jQuery(document).ready(function() {
var refreshId = setInterval(function()
{
jQuery('.main').load('/forum .main-box, #pun-info');
}, 10000);
jQuery.ajaxSetup({ cache: false });
});
The result.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: auto refresh div content ...
Well from what I see, again you're using .main; the element you'll load the content into. Since you didn't specifically tell the browser which .main to add to, it will instead add the content to all elements with class="main".
Re: auto refresh div content ...
Yes i know. but i want load .main-box and #pun-info. what i use here?
jQuery('????').load('/forum .main-box, #pun-info');
jQuery('????').load('/forum .main-box, #pun-info');
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: auto refresh div content ...
Give me an example. auto refresh .main-box and #pun-info with one load.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Similar topics
» auto refresh
» I would like to add auto-refresh
» auto refresh
» Auto Refresh on Portal
» page auto refresh
» I would like to add auto-refresh
» auto refresh
» Auto Refresh on Portal
» page auto refresh
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum