By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,280 Members | 2,244 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,280 IT Pros & Developers. It's quick & easy.

Problem with dynamic content in Javascript/Ajax

P: 10
Hi,
I am using AJAX to display dynamic RSS feeds in my web page.
So on page load i am callin the AJAX function Start_Timer() The body of Start_Timer() is as follows.

function Start_Timer()
{
getRSS(); //This is the function which gets the RSS feeds and displays it in a div tag in the page.
t=setTimeout("Start_Timer()",6000);
}

So according t this code every 6 seconds the function getRSS() should be called which updates the dynamic feed on the web page is it not?
But though the function is called every 6 seconds,it does not display the feed dynamically.Like for example if i delete the source feed,the script still displays the feed on the webpage and does not give an error.
Any idea what the problem is how do i rectify it? I would greatly appreciate any help.
Thanks
Satish
Apr 11 '07 #1
Share this Question
Share on Google+
7 Replies


iam_clint
Expert 100+
P: 1,208
try t=window.setTimeout("Start_Timer()",6000);
Apr 11 '07 #2

P: 10
Hi,
Thanks for your reply. I tried that but it didnt work.In fact even if i try doing a simple document.write("test") in the page in the function Start_Timer() ,it just executes it once instead of in a periodic manner.
Thanks again
Apr 11 '07 #3

iam_clint
Expert 100+
P: 1,208
var t=window.setTimeout("Start_Timer()",6000);


let me see your other function
Apr 11 '07 #4

P: 10
Hi,
I was testing this application some more with different browsers and I find that it works fine in opera but gives problem(ie not updating dynamic feed) in IE and firefox. I am guessing it is due to some cache problem.
But in my script function I added a line

<CODE> ajaxobject.setRequestHeader("Cache-Control","no-cache") <CODE> where ajaxobject is my XMLHttpRequest() object

I thought this would make sure that the web page is updated everytime without using the cache.
Any ideas?
Thanks again
regds
Apr 11 '07 #5

acoder
Expert Mod 15k+
P: 16,027
You could try something like:
Expand|Select|Wrap|Line Numbers
  1. url=url+"&sid="+Math.random();
to prevent caching.
Apr 12 '07 #6

P: 10
yup...adding a random number to the url worked...
thanks!
Apr 13 '07 #7

acoder
Expert Mod 15k+
P: 16,027
No problem. You're welcome.
Apr 13 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.