requesting data periodically

requesting data periodically

Hi,

I am new to Javascript and jQuery.

Basically, I am using the GoogleMaps API to plot markers on a map. I get the lonng/lat data from a database.

I initially fetch the data from the database through a request to a PHP script as follows:

  1. $.getJSON("mapservice.php?action=listpoints", function(json) {
                        if (json.Nodes.length > 0) {
                            for (i=0; i<json.Nodes.length; i++) {
                                var location = json.Nodes[i];
                                addLocation(location);
                            }
                        }
                    });












Now, in addition to that I would like to periodically check whether there is new data and fetch that data. I have already written the PHP script that handles this, however I am not sure on how to implement it jQuery.
How can I request the data e.g. every 5 secs from the PHP script?

Any help will be much appreciated.

Thanks in advance.