Answer the question
In order to leave comments, you need to log in
Cross-Origin Read Blocking (CORB) blocked cross-origin response with MIME type application/json How to solve?
Good day.
I ran into a problem when sending a request to the Vkontakte API. I searched for a solution to the problem, but did not find it.
I realized that you can’t send a request from one domain to another just like that, but I didn’t understand how to solve it.
Used 2 ways to connect.
Method number 1:
<script type="text/javascript">
var script = document.createElement('SCRIPT');
script.src = "https://api.vk.com/method/board.getComments?&group_id=54767201&topic_id=38534787&access_token=bb33ea88418164920d56079a8d50bacef683fcc323327336b3deb89a4ce77267cfaa0e792acb8dcbe15d1&v=5.131";
document.getElementsByTagName("head")[0].appendChild(script);
function callbackFunc(result) {
console.log(result.response);
}
console.log(response);
</script>
<script type="text/javascript">
let xhr = new XMLHttpRequest();
xhr.open('GET', 'https://api.vk.com/method/board.getComments?&group_id=54767201&topic_id=38534787&access_token=bb33ea88418164920d56079a8d50bacef683fcc323327336b3deb89a4ce77267cfaa0e792acb8dcbe15d1&v=5.131', true);
xhr.onload = function() {
if (xhr.status === 200) {
let data = JSON.parse(xhr.responseText);
console.log(data);
} else {
alert(xhr.status);
}
};
xhr.send();
console.log(1)
</script>
Answer the question
In order to leave comments, you need to log in
You need to proxy the request through your server (website). What is your website running on? In PHP?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question