I know this has been asked before - hear me out, because this is not working for me. This is my AJAX function:
$.ajax({
method: 'POST',
url: "https://somedomain.org",
contentType: "application/json; charset=utf-8",
dataType: 'json',
crossDomain: true,
headers: {
"Access-Control-Allow-Origin": "http://www.example.org",
"Access-Control-Allow-Headers": "X-Foo",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS"
},
data: JSON.stringify(generateCartParams()),
context: document.body,
success: function (response) {
console.log(response);
}
});
However, this is still getting me an error:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Am I not configuring the settings right?
Edit: I am, of course, setting url
and Access-Control-Allow-Origin
to the correct addresses - these are just placeholders for this question.