title: Refused to execute script from Shopify
body: <p>I'm trying to add an item to shopify, without any page refresh or redirect with:</p>
  
  <pre><code>     $.ajax({
              type: 'POST',
              url: 'https://xxx.myshopify.com/cart/add.json',
              dataType: 'jsonp',
              data: 'quantity=1&amp;id=234234234',
              success: function () {
                // show stuff
              }
            });    
  </code></pre>
  
  <p>But chrome says:</p>
  
  <pre><code> Resource interpreted as Script but transferred with MIME type text/html: "https://xxx.myshopify.com/cart".
  (index):1 Refused to execute script from 'https://xxx.myshopify.com/cart/add.json?callback=jQuery21304121434052940458_1422539760164&amp;quantity=1&amp;id=234234234&amp;_=1422539760165' 
  because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
  </code></pre>
  
  <p>I've tried other ways, like instead of <code>jsonp</code> do <code>json</code>, but then I offcourse get a CORS warning.</p>
  
  <p>Is there any way to change the expected MIME type?</p>
  
  <p>It's strange because doing: </p>
  
  <pre><code> $.ajax({
          type: 'GET',
          url: 'https://xxx.myshopify.com/cart.json',
          dataType: 'jsonp',
          success: function(data) { 
             // get stuff
          }
      }); 
  </code></pre>
  
  <p>DOES get met the shopify store data object.</p>
  
  <p>I realize there is no real official shopify javascript API, and it seems they REALLY don't wan't you to remotely add stuff to the cart without either refreshing your page or redirecting.</p>
  
  <p>To be clear, when I try to use their example:</p>
  
  <pre><code>    &lt;form id="shop" action="http://xxx.myshopify.com/cart/add" method="post" &gt;
          &lt;input type="hidden" name="id" value="234234234" /&gt;
            &lt;input type="hidden" name="return_to" value="back" /&gt;
             &lt;input type="submit" value="BUY STUFF"  /&gt;
      &lt;/form&gt;    
  </code></pre>
  
  <p>It will refresh the page to /#, 
  I tried e.preventDefault, but that doesn't submit the form offcourse.  </p>
  
  <p>Their iframe embed doesn't have any option to not redirect.</p>
  
  <p>Look, one possibility would be to create a 'mock' shopping cart on the site 'locally', then in the end send it in one request, and redirect to the store so people can finish their order, but there must be a better way. </p>
  
  <p>Lastly I looked at: <a href="http://mayert-douglas4935.myshopify.com/pages/api" rel="nofollow">http://mayert-douglas4935.myshopify.com/pages/api</a>
  But the problem is that that's made for use within a shopify shop, so within the domain, so changing all the:</p>
  
  <p>url: '/cart/add.js',</p>
  
  <p>lines of that API's ajax params into:</p>
  
  <p>url: '<a href="https://xxx.myshopify.com/cart/add.js" rel="nofollow">https://xxx.myshopify.com/cart/add.js</a>',</p>
  
  <p>it won't work because it uses 'json' instead of 'jsonp', and changing that will result in the same above MIME type problem.</p>
  
  <p>Anyone know about some simple custom code that allows for an item to be added to the cart? That's pretty much all I need. Add to cart from remote, just an async request and response...</p>
  
  <p><strong>UPDATE:</strong> 
  I tried <code>/change.json</code> instead of <code>/add.json</code>, now the MIME type error is gone, but the ajax request gives back an error event. HOWEVER, the changes are made... (and it gives an <code>complete</code> event back, with a <code>.statusText:'error'</code>) So, I could use this to build my remote side of the store, but you can understand, this is not really a solution.</p>