title: Cannot send cross domain ajax request with post method
body: <p>I wrote rest service with <code>spring mvc</code>:  </p>
  
  <pre><code>@RequestMapping(value = "/login", headers="Accept=*/*", method = RequestMethod.POST,
          produces="application/json")
  @ResponseStatus(HttpStatus.OK)
  @ResponseBody
  public UserLoginedVO findUsByPass(HttpServletResponse response, 
          @RequestBody UserLoginCO userco) throws Exception{
  
      response.setHeader("Access-Control-Allow-Origin","*");
  
      UserLoginedVO usVO = userService.findUsByPass(userco.getUsername(), userco.getPassword());
      return usVO;
  }
  </code></pre>
  
  <p>test with postman, it returns right result
  I call this service by jquery like below:</p>
  
  <pre><code>var json = {"username":"giau", "password":"1234"};
  
  $.ajax({
              data: JSON.stringify(json),
              url: 'http://192.168.1.119:8080/mos/api/users/login',
              type: 'POST',
              dataType: 'json',
              contentType:"application/json", 
              crossDomain:true,
              async:false,
              success:function(data)
              {
                 alert("Data from Server"+JSON.stringify(data));
              },
              error:function(jqXHR,textStatus,errorThrown)
              {
                 alert("You can not send Cross Domain AJAX requests: "+errorThrown);
              }
          }).done(function(data){
              alert("aaaaaa");
          });
  </code></pre>
  
  <p>I get an error: </p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load.<br>
     No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. </p>
    
    <p>Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource This can be fixed by moving the resource to the same domain or enabling CORS.</p>
  </blockquote>
  
  <p>This disallows post json data to rest service with cross domain, although I use <code>crossDomail:true</code> </p>
  
  <p>How can I fix this? </p>