I have a js file named get-chat.js that calls a function every 1 second:
setInterval(function () {
//start ajax
let xhr = new XMLHttpRequest(); //creating XML object
xhr.open('POST', 'get-chat.php', true);
xhr.onload = () => {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
let data = xhr.response;
chatBox.innerHTML = data;
}
}
}
//send the form data through ajax to php
let formData = new FormData(form);
xhr.send(formData);
}, 1000);
this function executes an XML Ajax call that redirects to the get-chat.php page, which retrieves all messages with certain characteristics from a database.
As long as this script is executed on a localhost, everything works correctly. When the script is loaded on a web host (not localhost) I receive the following error:
Cross-origin read blocking (CORB) blocked the cross-origin response with MIME type text/html
I have already looked for information on CORB, but I cannot figure out how to solve it.
Can anyone help me? Thanks
PS: chatBox is a variable declared outside the function
UPDATE:
I add the response headers and payload as requested