Answer the question
In order to leave comments, you need to log in
How to write xhr cross domain post for livetex chat?
Greetings.
The first time I encountered cross-domain requests and I still can’t parse them. There is a task on the chat api livetex.github.io/messaging-api to build a chat. When I try to send a message, I get a response
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 404.
$.ajax({
url: this.urlGen(),
type: "POST",
data : this.msgGen(),
// contentType: 'application/json',
headers: {
"Access-Control-Allow-Origin": "*"
},
dataType: 'json',
success: function (response) {
workForm.switch()
console.log('Success',response);
},
error : function (response) {
console.error('Error',response);
}
});
Answer the question
In order to leave comments, you need to log in
Access-Control-Allow-Origin must be set on the server, i.e. at livetex.github.io/messaging-api
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question