title: jQuery Basic Auth error sending credentials
body: <p>Having an issue where I "think" the credentials aren't being set even though there specified in beforeSend. It's all setup to be dynamic, including headers and basic auth (it's for api docs).</p>
  
  <p>Basic auth is being passed in fine i.e : "Basic XXXXXXXX"</p>
  
  <p>Server has Access-Control-Allow-Origin "*"</p>
  
  <pre><code>var $button = $(this).button('loading'),
      $parent = $(this).parents('.api-test-response:first'),
      $data = $('.api-test-data',$parent),
      headers = {};
  
   $('.api-test-headers tr',$parent).each(function(){
       if($('.header-toggle', this)[0].checked &amp;&amp; $('input.api-test-header-key',this).val() != ""){
           headers[$('input.api-test-header-key',this).val()] = $('input.api-test-header-value',this).val();
       }
   });
  
   $.ajax({
    async: false,
    cache: false,
    crossDomain: true,
    headers: headers,
    beforeSend: function(xhr) {
      if(headers['Authorization']){
        xhr.withCredentials = true;
        xhr.setRequestHeader('Authorization', headers['Authorization']);                           
      }
      return true;
    },
    url: this.dataset.url,
    method: this.dataset.method || 'get',
    dataType: this.dataset.type || 'json',
    data: $data[0] ? $data[0].value : '',
    success: function(data, status, jqXHR){
      $('pre', $parent).removeClass('hide').find('code').html( !data ? status : data instanceof Object ? syntaxHighlight(data) : data );
    },
    error: function(jqXHR, status, error){
      $('pre', $parent).removeClass('hide').find('code').html( '&lt;div class="badge badge-important"&gt;'+ jqXHR.status +'&lt;/div&gt; ' + (jqXHR.responseText != '' ? jqXHR.responseText :  status + ' ' + error) );
    }
  
  })
    .always(function (jqXhr) {
        $button.button('reset');
        $("body").scrollspy('refresh');
    })
  </code></pre>
  
  <p>Error from chrome :  </p>
  
  <pre><code>OPTIONS URL 401 (Unauthorized)
  XMLHttpRequest cannot load URL. Invalid HTTP status code 401
  
  Response : No Authorisation Provided 
  </code></pre>