title: JQuery. $.post request .done() .fail() avoid code duplication
body: <p>I have a post request like</p>
  
  <pre><code>  $.post("test", {
      ajax: "true",
      action: ""
    }).done(function(data){
      if (data == "ok"){
          //xxx
      } else if (data == "err"){
          //yyy
      }
    }).fail(function(){
      //yyy
    });
  </code></pre>
  
  <p>How to avoid code duplication in the post request if code in .done() method (comment 'yyy') the same in fail method (comment 'yyy') ?? </p>