My AJAX based refresh is not working

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Antonio Vianello on 7th April 2013
Hi there.

I have a problem with AJAX based refresh of a scattered date/time chart.
On my server side ther's a simple PHP script called with some GET parameters that fetches data every 60 seconds from a MySQL storage; my AJAX request looks like that:

window.onload = function (e)
   RGraph.AJAX('http://' + + '/ajaxtest/fetchMySQLData.php?param=<?php print $param; ?>', myXMLProcessor);
   setTimeout(window.onload, 60000); // 60000 milliseconds = 1 minute

but surprisingly that script seems to get called only the first time, i.e. the graph still shows the same data (and I'm sure that they change on the database!), while the client side gets called regularly every minute, because I can see the changes that I make on its structure (i.e. the background color of the chart)

I've checked this strange behaviour because in my development environment (Eclipse PHP) when I put a breakpoint on that script it never stops there after the first time it did.

It seems that there's some sort of cacheing on the server side...

Any suggestions?

Thanks in advance
Posted by RGraph support on 8th April 2013
Hi there,

Change this line:

RGraph.AJAX('http://' + + '/ajaxtest/fetchMySQLData.php?param=<?php print $param; ?>', myXMLProcessor);

to this:

var url = 'http://' + + '/ajaxtest/fetchMySQLData.php?param=<?php print $param; ?>';
RGraph.AJAX(url, myXMLProcessor);

So that you can see the URL that is being requested. And reduce the setTimeout delay to 5000 so that you're not waiting around. Also you could try adding a random query string to the URL to help prevent caching:

url = url + '&rand=' + RGraph.random(0,999999);

Richard, RGraph Support
Posted by Antonio Vianello on 8th April 2013
Dear Richard,

thanks for the reply but despite your suggest i still receive the same data... :-(
I've noticed however that this strange behaviour only happens using MS Explorer 9.0 (I din't check with older versions) and never, for example, with Mozilla Firefox...

Could it be a browser compatibility issue?

Posted by RGraph support on 8th April 2013
Hi there,

I doubt it. I've modified the basic AJAX demo adding a button that you can press to retrieve new data. Use it as a template if you wish.


Add a reply

« Back to message list