title: Is it Possible to Make Cross-Domain Requests in Javascript AND Set Custom Headers?
body: <p><a href="https://stackoverflow.com/questions/3073287/set-headers-with-jquery-ajax-and-jsonp">Since you can't apply custom headers on JSONP calls</a>, how do I make cross domain requests AND apply custom headers using jQuery?</p>
  
  <p>I'm basically trying to access google docs with jQuery and need to pass an authentication token:</p>
  
  <pre><code>var token = "my-auth-token";
  $.ajax({
    url: "http://docs.google.com/feeds/documents/private/full?max-results=1&amp;alt=json",
    dataType: 'json',
    beforeSend: function(xhr) {
      xhr.setRequestHeader("Authorization", "GoogleLogin auth=" + token);
    },
    success: function(data, textStatus, XMLHttpRequest) {
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
    }
  });
  </code></pre>
  
  <p>Note: The goal of this is to <em>completely</em> bypass the application layer.  It's simple to use ruby to connect to the Google Data API, but it takes up a lot of resources parsing feeds all the time server-side.</p>