Я создаю страницу входа, используя HTML, и мой API для входа в систему - REST API (django).Во время работы он показывает, что политика cors была заблокирована.Как исправить эту ошибку?Я должен изменить в каком-либо сценарии Java или в API.
var username=document.getElementById('UserName').value;
var password=document.getElementById('Password').value;
var http = new XMLHttpRequest();
var url = 'https://creativedsapi.kdns.in/hrapi/login';
var params={
"username":username,
"password":password
};
http.open('POST', url, true);
//Send the proper header information along with the request
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.setRequestHeader("Content-Type", "application/json");
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState === 4 && http.status === 200) {
alert(http.responseText);
}
}
http.send(JSON.stringify(params));