title: S3: No 'Access-Control-Allow-Origin' for AJAX POST
body: <p>This issue is driving me a little nuts.  I'm trying to upload files via AJAX POST to an S3 bucket.</p>
  
  <p>I have all the credentials correct because when I do normal HTTP POSTs it creates the resource in the S3 bucket just fine.  But I would really like to upload multiple file at once with progress bars, hence I need AJAX.</p>
  
  <p>I have CORS setup on my S3 bucket:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"&gt;
      &lt;CORSRule&gt;
          &lt;AllowedOrigin&gt;http://localhost:3000&lt;/AllowedOrigin&gt;
          &lt;AllowedMethod&gt;GET&lt;/AllowedMethod&gt;
          &lt;AllowedMethod&gt;POST&lt;/AllowedMethod&gt;
          &lt;AllowedHeader&gt;*&lt;/AllowedHeader&gt;
      &lt;/CORSRule&gt;
  &lt;/CORSConfiguration&gt;
  </code></pre>
  
  <p>Right now I'm just trying to get it working in my development environment (localhost:3000, using standard Rails 4.1).</p>
  
  <p>From my understanding, the above CORS rule should allow AJAX requests from localhost:3000 to the S3 bucket.</p>
  
  <p>However, every time I submit a file via AJAX, I get the following error:</p>
  
  <pre><code>XMLHttpRequest cannot load https://s3.amazonaws.com/&lt;BUCKET&gt;. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
  </code></pre>
  
  <p>This doesn't make any sense to me because localhost:3000 IS granted access via the CORS rule.</p>
  
  <p>I've also provided a snippet of the JS I used to submit the form:</p>
  
  <pre><code>  $.ajax({
      method: "POST",
      crossDomain: true,
      url: "https://s3.amazonaws.com/&lt;BUCKET&gt;",
      data: $(this).serialize() # Contains S3 necessary values
    })
  </code></pre>
  
  <p>The form has inputs for the Amazon S3 keys/etc necessary.  I know they work because when I do normal HTTP POSTs it creates the asset properly in S3.  All I'm trying to do is AJAXify the process.</p>
  
  <p>Am I missing something obvious here?</p>
  
  <p>Using: Rails 4.1, jquery-file-upload, fog gem (for S3)</p>