view contests/static/js/contests/contests.js @ 951:5366c29d6dce

Django's SortedDict is gone. Use OrderedDict instead. For Django 1.7.8 upgrade.
author Brian Neal <bgneal@gmail.com>
date Sat, 16 May 2015 18:51:12 -0500
parents ee87ea74d46b
children 16e190fa6ef8
line wrap: on
line source
$(function() {
   var $button = $('#contest-button');
   $button.click(function() {
      var buttonLabel = $button.text();
      $button.attr('disabled', 'disabled').val('Please wait...');

      $.ajax({
         url: '/contests/enter/', 
         type: 'POST',
         data: {
            contest_id : contest_id
         },
         dataType: 'json',
         success: function (data, textStatus) {
            var classname = data.entered ? 'success' : 'info';
            var $p = $('#contest-entry');
            $p.hide();
            $p.addClass(classname);
            $p.html(data.msg);
            $p.fadeIn(3000);
         },
         error: function (xhr, textStatus, ex) {
            alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + 
               xhr.responseText);
            $button.removeAttr('disabled').text(buttonLabel);
         }
      });
      return false;
   });
});