title: Proper status codes for JSON responses to Ajax calls?
body: <h3>My project is returning JSON to Ajax calls from the browser. I'm wondering what the proper status code is for sending back with responses to invalid (but successfully handled) data submissions.</h3>
  
  <p>For example, jQuery has the following two particular callbacks when making Ajax requests: </p>
  
  <p><code>success</code>: Fired when a 200/2xx status code is delivered along with the response. </p>
  
  <p><code>error</code>: Fired when 4xx, 5xx, etc, status codes come back with the response. </p>
  
  <p>If a user attempts to create a new "Person" object, I send back a JSON representation of the newly created object upon success, thus giving javascript access to the necessary unique ID's for the new object, etc. This, of course, is sent with a 200 status code. </p>
  
  <p>If a user submits malformed or invalid data (say, an invalid/incomplete "name" field), I would like to send back the validation error messages via JSON. (I don't see why this would be a bad thing). </p>
  
  <p><strong>My question is:</strong> in doing so, should I send a <strong>200</strong> status code, because I successfully handled their invalid data? Therefore, I'd be using the jQuery <code>success</code> callback, but simply check for errors... </p>
  
  <p><strong>Or</strong>, should I use a <strong>4xx</strong> status code, perhaps 'Bad Request', because the data they sent me is invalid? (and thus, use the <code>error</code> callback to do the necessary client-side notifications). </p>