title: POST changes to OPTIONS + Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header
body: <blockquote>
    <p>XMLHttpRequest cannot load <a href="http://xxx.xxx" rel="nofollow noreferrer">http://xxx.xxx</a>. Response to preflight
    request doesn't pass access control check: No
    'Access-Control-Allow-Origin' header is present on the requested
    resource. Origin 'null' is therefore not allowed access. The response
    had HTTP status code 500.</p>
  </blockquote>
  
  <p>I am trying to send a xml soap with ajax but  gives me that error. I have tried many option but nothing seems to work, here is the code:</p>
  
  <pre><code>var soapMessage =
                  '&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://xxx.xxx/"&gt;'+
                  '&lt;soapenv:Header/&gt;'+
                  '&lt;soapenv:Body&gt;'+
                     '&lt;wsdl:test1&gt;'+
                        '&lt;PUI&gt;12345&lt;/PUI&gt;'+
                     '&lt;/wsdl:test1&gt;'+
                 ' &lt;/soapenv:Body&gt;'+
               '&lt;/soapenv:Envelope&gt;';
  
              $.ajax({
                  url: 'http://xxx.xxx', 
                  type: 'POST',
                  dataType: 'xml', 
                  data: soapMessage, 
                  crossDomain: true,
                  processData: false,
                  contentType: 'text/xml; charset=\"utf-8\"',
                  headers: {
                      SOAPAction: "http://xxx.xxx"
                  },
                  success: function (msg, data) {
                      alert(msg);
  
                  },
                  error: function (msg, data) {
                      alert("Error");
                  }
              });
  </code></pre>
  
  <p>what am I doing wrong here? I send a POST action but it read it as OPTION.
  How to fix this?</p>
  
  <p>I use Boomerang Rest and Soap Client to test this service and it gives me response correctly. When I use my own program as above it gives me XMLHttpRequest cannot load <a href="http://xxxxx" rel="nofollow noreferrer">http://xxxxx</a>" error. I am using apache tomcat 6.0 and using a Java web Application for the code</p>