title: Authentication headers are not sending JQuery Ajax
body: <p>I have web server hosted in Apache Tomcat 7 with Basic authentication. I have Tomcat user 'tomcat' with role 'tomcat' and password 'tomcat'. Following are my web.xml file and script snippet in client side respectively.</p>
  
  <p>Web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ASCII"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"&gt;
    &lt;display-name&gt;testservice&lt;/display-name&gt;
    &lt;servlet&gt;
      &lt;description&gt;JAX-RS Tools Generated - Do not modify&lt;/description&gt;
      &lt;servlet-name&gt;testservice&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;testservice&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
      &lt;security-constraint&gt;
          &lt;web-resource-collection&gt;
              &lt;web-resource-name&gt;testservice&lt;/web-resource-name&gt;
              &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
              &lt;http-method&gt;GET&lt;/http-method&gt;
              &lt;http-method&gt;POST&lt;/http-method&gt;
          &lt;/web-resource-collection&gt;
          &lt;auth-constraint&gt;
              &lt;role-name&gt;tomcat&lt;/role-name&gt;
          &lt;/auth-constraint&gt;
  
          &lt;user-data-constraint&gt;
              &lt;!-- transport-guarantee can be CONFIDENTIAL, INTEGRAL, or NONE --&gt;
              &lt;transport-guarantee&gt;NONE&lt;/transport-guarantee&gt;
          &lt;/user-data-constraint&gt;
      &lt;/security-constraint&gt;
  
      &lt;login-config&gt;
          &lt;auth-method&gt;BASIC&lt;/auth-method&gt;
      &lt;/login-config&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Client script:</p>
  
  <pre><code>&lt;script src="jquery-1.10.2.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script language="javascript" type="text/javascript"&gt;
      $.ajax({
          type: "GET",
          beforeSend: function (request)
          {
              request.setRequestHeader("Authorization", "Basic  dG9tY2F0OnRvbWNhdA==");
          },
          url: "http://localhost:1222/testservice/rest/test/users",
          dataType:"jsonp",
          success: function(res) {
              alert(res); 
          },
          error: function(err) {
              alert(err);
          }
      });                    
  &lt;/script&gt;
  </code></pre>
  
  <p>I'm pretty sure about that there's no problem with Web Service and Basic authentication. But from client script, no authentication headers are sending. I tried <code>header:("Authorization","Basic  dG9tY2F0OnRvbWNhdA==")</code> too. But request is sending without authentication headers. Any help will be appreciated.</p>