title: How to handle response with undefined body?
body: <p>I understand that my issue is that jQuery is trying to parse the body of the response as json, but the body is undefined, and thus throws an error.</p>
  
  <p>I cannot change the response. This is the default response from Jenkins servers. It sends a 201, 404, or 500 in the header, which I would like to handle.</p>
  
  <p>my ajax:</p>
  
  <pre><code> $(document).ready(function () {
      $('#reviewForm').bootstrapValidator({
        ...stuff...
        ...validation...
    }) 
  
   .on('success.form.bv', function (e) {
  // Prevent form submission
  e.preventDefault();
  
  // Get the form instance
  var $form = $(e.target);
  
  // Use Ajax to submit form data
  $.ajax({
      type: 'POST',
      url: url+$form.serialize(),
      dataType: 'text',
      complete: function() {
          alert("Success.");
      },
      error: function(xhr, status, text) {
          alert("failure");
      }
  });
  </code></pre>
  
  <p>Despite a successful post (201 created), it will still hit error because of the syntax error due to the undefined body.</p>
  
  <p>I would gladly handle the errors in the error: part of ajax, but I cant for the life of me figure out how to get the status code out of the header of the response.</p>
  
  <p>And like I said, I would change the response if I could, but its just how Jenkins works.</p>
  
  <p>Thank you.</p>
  
  <p>EDIT: response header</p>
  
  <pre><code>Status Code: 201 Created
  Connection: Keep-Alive
  Content-Type: text/plain; charset=UTF-8
  Date: Wed, 01 Oct 2014 14:51:12 GMT
  Keep-Alive: timeout=15, max=100
  Location: https://jenkins....
  Server: Jetty(8.y.z-SNAPSHOT)
  Transfer-Encoding: chunked
  </code></pre>
  
  <p>and this is the xhr (xml http response)</p>
  
  <pre><code>{
  "readyState": 0,
  "status": 0,
  "statusText": "error"
  }
  </code></pre>