下面是我使用 XMLHttpRequest 的代码,但它显示以下错误,任何人都可以帮助我解决这个问题。
错误 1:open.html:24 选项 https://proxy.api.deepaffects.com/text/generic/api/latest/sync/text_recognise_emotion?apikey=xAur1Q9uSgipes2jnCBSTzPj8mJn4LP9 404(未找到)(匿名)@ open.html:24错误 2:无法加载 https://proxy.api.deepaffects.com/text/generic/api/latest/sync/text_recognise_emotion?apikey=xAur1Q9uSgipes2jnCBSTzPj8mJn4LP9:对预检请求的响应未通过访问控制检查:当请求的凭据模式为“包含”时,响应中的“Access-Control-Allow-Origin”标头不得为通配符“*”。因此,Origin 'null' 不允许访问。XMLHttpRequest 发起的请求的凭证模式由 withCredentials 属性控制。打开.html:15
var data = JSON.stringify({
"content": "it is not good"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://proxy.api.deepaffects.com/text/generic/api/latest/sync/text_recognise_emotion?apikey=xAur1Q9uSgipes2jnCBSTzPj8mJn4LP9");
xhr.setRequestHeader("content-type", "application/json");
xhr.send(data);