Skip to content

Commit

Permalink
Clean up AJAX error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
watson committed Dec 24, 2017
1 parent ba3ed46 commit de15bfe
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions assets/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,18 @@ function initMap () {
map.addListener('zoom_changed', zoomLevelChanged)

onJQuery(function () {
// eslint-disable-next-line no-undef
$.getJSON('airports', plotAirports)
.fail(function (jqXHR, textStatus, err) {
throw err
})

// eslint-disable-next-line no-undef
$.getJSON('airlines', parseAirlines)
.fail(function (jqXHR, textStatus, err) {
throw err
})

$.getJSON('airports', plotAirports).fail(onAjaxError) // eslint-disable-line no-undef
$.getJSON('airlines', parseAirlines).fail(onAjaxError) // eslint-disable-line no-undef
setInterval(function () {
// eslint-disable-next-line no-undef
$.getJSON('aircrafts', plotAircrafts)
.fail(function (jqXHR, textStatus, err) {
throw err
})
$.getJSON('aircrafts', plotAircrafts).fail(onAjaxError) // eslint-disable-line no-undef
}, 2000)
})
}

function onAjaxError (jqXHR, textStatus, err) {
throw err
}

function zoomLevelChanged () {
const level = map.getZoom()
airportMarkers.forEach(function (marker) {
Expand Down

0 comments on commit de15bfe

Please sign in to comment.