I'm working with a project including placing some markers at a Leaflet map. I use PostGIS to store the markers. I use Django as backend. When I try to access the markers through a $.getJSON it files silently.
This is the code that fails:
function sendCategories(map){
var checks = $('input[type="checkbox"]:checked').map(function(){
return $(this).val();
}).get();
var liste = JSON.stringify(checks);
var categories ="{% url 'events:listEvents' 12345 %}".replace(/12345/,liste);
$.getJSON(categories, function(data) {
L.geoJSON(data).addTo(map);
});
}
What is interesting is that I have this piece of code, that does simiar things, but works properly:
function addEvents(map) {
var EventPoints = "{% url 'events:pointData' %}";
$.getJSON(EventPoints, function (data) {
L.geoJSON(data).addTo(map);
});
}
Both of the urls haves the same data, I did check it multiple times.
When I try to log the error I get this:
getJSON failed, status: error, error:
Okay, it looks like the error with getJSON was caused by a form that refreshed the page. When I added event.preventDeafult()
getJSON started to work.