function dform(formElement) {
  var eventEmitter = {
    on: function (name, handler) {
      this[name] = this[name] || [];
      this[name].push(handler);
      return this;
    },
    trigger: function (name, event) {
      if (this[name]) {
        this[name].map(function (handler) {
          handler(event);
        });
      }
      return this;
    }
  };
  var submitElement = formElement.find('[type=submit]');
  var inputElements = formElement.find('input, select');
  formElement.submit(function (event) {
    event.preventDefault();
    var formData = {};
    $.each(inputElements, function (_, element) {
      element = $(element);
      var name = element.attr('name');
      if (name) {
        formData[name] = element.val();
      }
    });
    submitElement.attr('disabled', 'disabled');
    eventEmitter.trigger('submit');
    $[formElement.attr('method')](formElement.attr('action'), formData)
      .always(function () {
        submitElement.removeAttr('disabled', 'disabled');
      })
      .done(function (data) {
        eventEmitter.trigger('done', data);
      })
      .fail(function (jqXHR) {
        eventEmitter.trigger('fail', jqXHR);
      });
  });
  submitElement.removeAttr('disabled', 'disabled');
  return eventEmitter;
}

@@ -536,24 +536,72 @@
 tDefault();%0A
+    submitElement.attr('disabled', 'disabled');%0A
     var form
@@ -611,16 +611,16 @@
 a = %7B%7D;%0A
-
     $.ea
@@ -806,56 +806,8 @@
 %7D);%0A
-    submitElement.attr('disabled', 'disabled');%0A
     
@@ -1027,17 +1027,25 @@
 nction (
-d
+responseD
 ata) %7B%0A 
@@ -1080,17 +1080,25 @@
 'done', 
-d
+responseD
 ata);%0A  

Disable button should be the first thing to do