   ###
   near = "#{map.getCenter().lng}|#{map.getCenter().lat}" if not near
   url = "/api/c/challenges/#{challenge}/tasks?near=#{near}"
-  $.getJSON url, (data) ->
+  request = $.ajax {url: url}
+  request.done((data) ->
     currentTask = data[0]
-    showTask(data[0])
+    showTask(data[0]))
+  request.fail(ajaxErrorHandler)
 
 changeMapLayer = (layerUrl, layerAttrib = tileAttrib) ->
   ###

  ###
  # Gets a specific challenge
  ###
  $.getJSON "/api/c/challenges/#{id}", (data) ->
    challenge = data
    updateChallenge(challenge)
    updateStats(challenge)
    getTask()

getNewChallenge = (difficulty, near) ->
  ###
  # Gets a challenge based on difficulty and location
  ###
  near = "#{map.getCenter().lng}|#{map.getCenter().lat}" if not near
  url = "/api/c/challenges?difficulty=#{difficulty}&contains=#{near}"
  $.getJSON url, (data) ->
    challenge = data.challenges[0]
    updateChallenge(challenge)
    updateStats(challenge)
    getTask(near)

@getTask = (near = null) ->
  ###

  id = feature.properties.id
  mqurl = "http://open.mapquestapi.com/nominatim/v1/reverse?format=json&osm_type=#{type}@osm_id=#{id}"
  msgClose()
  request = $.ajax {url: mqurl}
  request.done((data) ->
    locstr = nomToString(data.address)
    msg locstr)
  request.fail(ajaxErrorHandler)

revGeocode = ->
  ###
