Skip to content

Instantly share code, notes, and snippets.

@yurifrl
Last active August 29, 2015 14:18
Show Gist options
  • Select an option

  • Save yurifrl/c18443cc99e058cb7045 to your computer and use it in GitHub Desktop.

Select an option

Save yurifrl/c18443cc99e058cb7045 to your computer and use it in GitHub Desktop.
Example of spree CORS ajax
$.ajax({
url: "http://charles.lvh.me/api/products",
method: "GET",
contentType: "application/json; charset=utf-8",
crossDomain: true,
beforeSend: function(xhr){
xhr.setRequestHeader('X-Spree-Token', 'a19d529a7ee5bc807a0b30b83adf998399f3c1804323f349');
xhr.setRequestHeader('Access-Control-Allow-origin', '*');
xhr.setRequestHeader('Access-Control-Allow-Methods', 'PUT, DELETE, GET');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment