title: Sending a recognizable error to JQuery from CakePHP
body: <p>I have the following JQuery code:</p>
  
  <pre><code> $('#dropdown').bind('change', function() {       
      var formData = $('#newform').serialize()
      $.ajax({
          type: 'POST',
          url: baseUrl+"crm/orders/ajaxEdit",
          data: formData,
          success: function(){ 
              console.log("ok");
          },
          error: function() {
              console.log("not ok");
          }
      });
   });
  </code></pre>
  
  <p>The <code>ajaxEdit</code> action is very simple:</p>
  
  <pre><code>    function ajaxEdit() {
          $this-&gt;layout = 'ajax';
          $this-&gt;autoRender = false;
          $this-&gt;Order-&gt;save($this-&gt;data['Order']);
      }
  </code></pre>
  
  <p>It works fine in that the data from the form is posted to the correct action in my CakePHP controller.</p>
  
  <p>However, regardless of whether the insert query in CakePHP is successful or not, the "ok" message gets echoed to the console unless the HTTP request fails or something.</p>
  
  <p>How can I get cake to send an error back to JQuery that JQuery will recognize as an error and echo "not ok" to the console in the event that there's a validation error or some other insert error in the Cake action?</p>