I would like to apologize for my level of English but I will try to do my best so to describe my problem. I have a small experience in javascript / html / ajax. I created a webgis with Leaflet. My code gets a geojson file and added to the map. My data have a big amount of size so I would like to have a loader as the user waits for the results. The scenario: The user press a button and below is the code of the button:
$("#btnFillData").click(function(){
if (mymap.hasLayer(lyrda)) {
mymap.removeLayer(lyrda);
}
var filePath=folderYears+fileMonths;
lyrda = L.geoJSON.ajax(filePath, {style:styleDataColors, onEachFeature:processLyr}).addTo(mymap);
});
I found this: How can I create a "Please Wait, Loading..." animation using jQuery?
I tried the above solution but I believe that I do not do what I must do. In the above solution we can see:
$body = $("body");
$(document).on({
ajaxStart: function() { $body.addClass("loading"); },
ajaxStop: function() { $body.removeClass("loading"); }
});
Where I should paste this code? Thanks in advance!