     timeframe = $('#timeframe option:selected').val()
     cumulative = $('#cumulative').is(':checked')
 
-    $.getJSON($SCRIPT_ROOT + '/info', {username})
+    getJSON($SCRIPT_ROOT + '/info', {username})
     .then (info) ->
       toDate = moment.utc()
       fromDate = switch timeframe

      Promise.map ranges, (range) ->
        [fromDate, toDate] = range
        params = {username, fromDate, toDate}
        $.getJSON($SCRIPT_ROOT + '/weekly-artist-charts', params)
        .then (weeklyCharts) ->
          progress += 1
          ladda.setProgress(progress / ranges.length)
          # if weeklyCharts.error?
          #   # Put error handling here
          weeklyCharts
        .fail ->
          # Failed to get weekly charts.
          ladda.stop()
      .then (weeks) ->
        weeklyCharts = {}
        for week in weeks.reverse()
          for key, value of week
            if key != 'error'
              weeklyCharts[key] = value
        drawChart(weeklyCharts, numberOfArtists, cumulative)
        ladda.stop()
        # $('.collapse').collapse()
    .fail ->
      # Failed to get user info.
      ladda.stop()

  return result


getJSON = (url, params) ->
  new Promise (resolve, reject) ->
    $.getJSON(url, params)
    .done (result) -> resolve(result)
    .fail (jqxhr, textStatus, error) -> reject(error)


$ ->
  $('#submit').click ->
    ladda = Ladda.create(this)
