title: To show JSON returned error message
body: <p>I needs to show the <strong><em>Json</em></strong> returned message. </p>
  
  <p>In the controller, an exception is thrown and caught in a catch block. I am returning the fault error message. </p>
  
  <p>In <strong><em>Ajax</em></strong>, the <em>success</em> part always executes. But if it is an error from my <strong><em>webservice</em></strong>, I don't want to execute the normal; instead I want to show an error message. </p>
  
  <p>How I can achieve this?</p>
  
  <p>My code below:</p>
  
  <h2>Controller</h2>
  
  <pre><code>[HttpPost]
  public JsonResult DeleteClientRecord()
  {
  
      bool result = true;
      try
      {
          result = ClientCRUDCollection.DeleteClient(deleteClientId);
  
      }
      catch (Exception ex)
      {
  
          return Json(ex.Message, JsonRequestBehavior.AllowGet);
      }
  
      return Json(new { result }, JsonRequestBehavior.AllowGet);
  }
  </code></pre>
  
  <h2>AJAX Call</h2>
  
  <pre><code>$("#YesDelete").click(function () {
      $.ajax({
          type: "POST",
          async: false,
          url: "/Client/DeleteClientRecord",
          dataType: "json",
          error: function (request) {
              alert(request.responseText);
              event.preventDefault();
          },
          success: function (result) {
              // if error from webservice I want to differentiate here somehow
              $("#Update_" + id).parents("tr").remove();
              $('#myClientDeleteContainer').dialog('close');
              return false;
          }
      });
  
  });
  </code></pre>
  
  <p>Please can anyone help me on this.</p>