title: jQuery - Send a cross-domain PUT/DELETE request
body: <p>I have 2 sub-domains: <strong>main.example.com</strong> and <strong>api.example.com</strong></p>
  
  <p>Both sit on the same machine.</p>
  
  <p>I am trying to send <strong>PUT/DELETE</strong> requests from <strong>main.example.com</strong> to <strong>api.example.com</strong> but it won't let me do it.</p>
  
  <p>Response headers, from <strong>api.example.com</strong>:<br></p>
  
  <pre><code>Access-Control-Allow-Origin: http://main.example.com
  Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
  </code></pre>
  
  <p>This is how the request is made:</p>
  
  <pre><code>$.ajax({
      url: 'https://api.example.com/script.cgi',
      type: 'PUT',
      success: function(result) {
          // Do something with the result
      }
  });
  </code></pre>
  
  <p>It throws me an error:
  <strong>Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at <a href="https://api.example.com/script.cgi" rel="nofollow">https://api.example.com/script.cgi</a>. This can be fixed by moving the resource to the same domain or enabling CORS.</strong></p>
  
  <p>How can I fix this? I wasted the whole day in trying to fix it but without success.</p>
  
  <p>P.S. does not work in chrome and firefox.</p>