when loading searchable locations, catch 304 not mofied and just keep the data
@@ -84,9 +84,14 @@ c3nav = {
}
},
_searchable_locations_timer: null,
- load_searchable_locations: function() {
+ load_searchable_locations: function(firstTime) {
c3nav._searchable_locations_timer = null;
- $.getJSON('/api/locations/?searchable', c3nav._searchable_locations_loaded).fail(function() {
+ $.ajax({
+ dataType: "json",
+ url: '/api/locations/?searchable',
+ success: c3nav._searchable_locations_loaded,
+ ifModified: true,
+ }).fail(function() {
if(c3nav._searchable_locations_timer === null) {
c3nav._searchable_locations_timer = window.setTimeout(c3nav.load_searchable_locations, c3nav.init_completed ? 300000 : 15000);
}
@@ -95,8 +100,8 @@ c3nav = {
_last_time_searchable_locations_loaded: null,
_searchable_locations_interval: 120000,
_searchable_locations_loaded: function(data) {
- // todo, do nothing on 304 not modified
c3nav._last_time_searchable_locations_loaded = Date.now();
+ if (data !== undefined) {
var locations = [],
locations_by_id = {},
labels = {};
@@ -117,6 +122,9 @@ c3nav = {
c3nav.locations = locations;
c3nav.locations_by_id = locations_by_id;
c3nav.labels = labels;
+ } else {
+ // 304, nothing to do!
+ }
if (!c3nav.init_completed) {
c3nav.continue_init();
}
