title: Sending authorization headers with jquery and ajax
body: <p>I have looked at the following questions here on stackoverflow with no luck in what im trying to do.  </p>
  
  <p><a href="https://stackoverflow.com/questions/9820170/ajax-authorization-request-headers-fails-again-and-again">Ajax Authorization Request headers fails again and again</a></p>
  
  <p><a href="https://stackoverflow.com/questions/8847748/jquery-ajax-unauthorized-401-error">jQuery Ajax Unauthorized 401 Error</a></p>
  
  <p><a href="https://stackoverflow.com/questions/2054316/jquery-sending-credentials-with-cross-domain-posts">Sending credentials with cross-domain posts?</a></p>
  
  <p>Here is my code that I currently have:
      </p>
  
  <pre><code>    $(document).ready(function() {
          $.ajax({
              url: 'http://sample.domain.com/script.php?name1=value1&amp;jsonp=?',
              type: 'GET',
              dataType: 'json',
              contentType: "application/json",
              beforeSend: function(xhr) {
                   xhr.setRequestHeader("Authentication", "Basic ZnJvbWFwcGx********uOnRoM24zcmQ1UmgzcjM=") //Some characters have been replaced for security but this is a true BASE64 of "username:password"
              },
              success: function(data){
                  alert(data);
              }
          });
      });
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p>The subdomain I have is password protected by an .htpasswd file.  The login of the site works just fine for me using the username/password combo used in the base64 encode.</p>
  
  <p>Im running this script on a different domain than the one that the url is on which is why i have the jsonp=? in the url</p>
  
  <p>The response im getting from the console in the browser is:
      <code>GET http://sample.domain.com/script.php?name1=value1&amp;jsonp=jsonp1334177732136 401 (Authorization Required)</code></p>