I have a website that reads from a MySQL database and displays the most recent data on a map. How can I make this data refresh on the website once a second? Do I need to put my AJAX code in a timer? Does the PHP script that queries the database need to be on a timer?
var geojson;
$(document).ready(function () {
var a = $(this).val();
console.log(a)
$.ajax({
type: "POST",
url: "b.php",
async: false,
data: {c: a},
datatype: 'json',
success: function (d) {
var e = JSON.parse(d);
geojson = e;
new L.GeoJSON(e);
L.geoJSON([e], {
onEachFeature: onEachFeature,
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, {
fillColor: "#ff0505",
fillOpacity: 1,
radius: 5,
weight: 1
});
}
}).addTo(mymap);
}
})
});