Answer the question
In order to leave comments, you need to log in
How to disable CORS on openserver?
I want to make a request to another site via js from localhost. Here is my js:
// Отправка данных на сервер
function send(event, asite){
console.log("Отправка запроса");
event.preventDefault ? event.preventDefault() : event.returnValue = false;
var req = new XMLHttpRequest();
req.open('POST', asite, true);
req.onload = function() {
if (req.status >= 200 && req.status < 400) {
json = JSON.parse(this.response);
console.log(json);
// Если не удалось связаться
} else {alert("Ошибка сервера. Номер: "+req.status);}};
// Если не удалось отправить запрос. Стоит блок на хостинге
req.onerror = function() {alert("Ошибка отправки запроса");};
req.send(new FormData(event.target));
}
...has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Access-Control-Allow-Origin:*
. I do this, but in the end my page does not open at all (error 500). Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question