I've been trying to update the latitude and longitude from an API. The API changes its data on real time. I tired using jQuery with an interval of 1000, but unfortunately it didn't fetch data from the API on the interval time given. It fetches the JSON for the first time but does not update it with respect to the interval given
<div id="info"><div>
<script>
function update(){
$.getJSON("http://track.gvhub.co/api/livetrack", function (data) {
$.each(data, function (key, value) {
var lat = parseFloat(data.lat)
var lon = parseFloat(data.lon)
$("#info").append(key + ":" + value + "<br>");
console.log(data.lat, data.lon)
})
})
}
setInterval(update(), 1000);
</script>