2
After this update of Google Chrome to version 53, I am facing problems in calls Ajax (jQuery), $.http (Angularjs) and Xmlhttprequest (Javascript) presenting the following message:
XMLHttpRequest cannot load *. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '*' is therefore not allowed access. The response had HTTP status code 400.
In a similar call from another service, with the same characteristics, I received the following message:
XMLHttpRequest cannot load *. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '*' is therefore not allowed access. The response had HTTP status code 405.
An example call is the following:
var data = JSON.stringify(false);
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("PUT", "*");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("accept", "application/json");
xhr.send(data);
I also can’t run in Firefox and Internet Explorer, but it used to work in Chrome, when making calls in Postman or Backend method they run correctly.
I am facing this problem because I am implementing one of the api’s in a Landing page without backend, so I need to use only call Javascript or jQuery the page.
Someone can help me?
Related: http://answall.com/q/145490/132
– Victor Stafusa
@Victorstafusa I’m consuming an external API, so it has to have http, and it’s an api used by other companies in different domains, so technically, there’s already correct, and I can make backend calls (php, .net) but I’m not getting it via client side
– Caio Gomes