title: Disable submit button until Ajax Completes
body: <p>I'm trying to disable a submit button until an ajax function is completed.  </p>
  
  <p>Right now, I have only been able to figure out how to disable the button for a specified time when the user is typing.</p>
  
  <p>How can I disable the submit button until the ajax data loads?  Thank you.</p>
  
  <pre><code>&lt;script&gt;
  
      $('#comment_comment').keyup(function() {
        $("#new_comment_button").attr("disabled", true);
        setTimeout(function() { $("#new_comment_button").removeAttr("disabled"); }, 2000);
      });
  
      $('#comment_comment').preview({ key:'my key', 
        selector : {type:'rich'},
        preview : {
          submit : function(e, data){
            $.ajax({
              dataType: 'script',
              url: this.form.attr('action'),
              type: 'POST',
              data: data
            });
          },
        },
        autoplay : 0,
        maxwidth : 350,
        display : {display : 'rich'}
      });
  
  &lt;/script&gt;
  </code></pre>