Blocked by CORS policy on Ajax

carat
New Member
4 0 0

Hi Team,

I am trying to add the product outside the Shopify with ajax as follows -

 $.ajax({url: "https://storename.myshopify.com/cart/add?id={varient_id}", success: function(result){
}});

 

But I am getting a "has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource" error.

I am listing the product outside Shopify and then with the ajax I want to add the product to the respective user's cart.

With the permalink (ex -https://storename.myshopify.com/cart/add?id={varient_id} ) it is working but the page is redirecting and I don't want page redirection/reload hence use of ajax call it's giving the above error.

 

Is there any solution to this?

0 Likes