title: jQuery code after ajax runs before ajax is completed
body: <pre><code>$("form#go").submit(function(){
      var $this = $(this);
      var btn = $this.find("button");
      btn.text("Searching").attr('disabled','disabled');
      $.ajax({
          url:
          type:
          data:
          dataType:
                      success:function(result){
               //code....
                      }
      });
      btn.text("Go").removeAttr('disabled');
  
      return false;
  });
  </code></pre>
  
  <p>This is my code structure. The problem is <code>btn.text("Go!").removeAttr('disabled');</code> runs immediately and I can't see the disabled button and the change of button text , although the ajax part takes 500ms to finish. </p>
  
  <p>If I change the last part to</p>
  
  <pre><code>setTimeout(function () {
       btn.text("Go").removeAttr('disabled');
   }, 1000);
  </code></pre>
  
  <p>Then I can see the change for 1 second, so I guess my code works. But I have no idea why it runs before the <code>ajax</code> call.</p>