title: resteasy ajax request
body: <p>I have a RestEasy api, and I need to provide access to all http methods to a mobile client, all those request must be sent via ajax.</p>
  
  <p>Here is an example of the client code:</p>
  
  <pre><code>var data = {
     login: 'usertest@gmail.com',
     password: '123456'
   };
  
   $.ajax({
     url: 'http://1.1.1.3:8080/api/admin',
     type: 'POST',
     contentType : 'application/json',
     dataType: "json",
     data: JSON.stringify(data),
     success: function(){
       console.log(arguments);
     },
     error: function(){
       console.log('error')
     }
   });
  </code></pre>
  
  <p>And here of the server:</p>
  
  <pre><code>@POST
  @Consumes("application/json")
  @Produces("application/json")
  public Response doLogin(User user) {...}
  </code></pre>
  
  <p>And here is the error: </p>
  
  <pre><code>XMLHttpRequest cannot load http://1.1.1.3:8080/api/admin. Origin http://stackoverflow.com is not allowed by Access-Control-Allow-Origin.
  </code></pre>
  
  <p>Here's my header answer from the server when I request from Localhost</p>
  
  <pre><code>Access-Control-Allow-Cred...    true
  Access-Control-Allow-Orig...    http://1.1.1.3:8080 //request sent from http://1.1.1.3:8080
  Access-Control-Expose-Hea...    X-Test-2, X-Test-1
  Content-Length  1136
  Content-Type    text/html;charset=utf-8
  Date    Wed, 19 Dec 2012 17:54:19 GMT
  Server  Apache-Coyote/1.1
  </code></pre>
  
  <p>PS: Everything works fine via usual http requests.</p>
  
  <p>What am I missing?</p>