<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
var token = "23453245eadab98f6ec9e0dab170ce39cf2f588895544483a2"
var day = 1
var arr = [];
function sendRequest() {
var request5 = new XMLHttpRequest();
request5.withCredentials = true;
request5.open('Get', 'https://api.vk.com/method/users.search?sort=1&count=10&city=1&country=1&sex=1&status=6&age_from=18&age_to=18&birth_day=' + day + '&access_token=' + token + '&v=5.52', true);
request5.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
request5.onload = function() {
var i = 0;
var json = this.response;
var data = JSON.parse(json);
var data2 = data.response.items
// arr = [data2];
for (i = 0; i < data2.length; i++) {
arr.push(data2[i].id);
}
}
request5.send();
day++
setTimeout (function(){document.querySelectorAll('textarea')[0].innerText=arr; },5000)
}
setTimeout (sendRequest ,3000);
</script>
</head>
<body>
<p><textarea name="comment"></textarea></p>
</body>
</html>
не делает запрос из хтмл файла. с консоли норм данный код отрабатывает .
ошибка
Access to XMLHttpRequest at 'https://api.vk.com/method/users.search?sort=1&count=10&city=1&country=1&sex=1&status=6&age_from=18&age_to=18&birth_day=1&access_token=5345872b24a247316ed25791ec4be02d469587eadab98f6ec9e0dab170ce39cf2f588895544483a2&v=5.52' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
index.html:28 Cross-Origin Read Blocking (CORB) blocked cross-origin response [url]https://api.vk.com/method/users.search?sort=1&count=10&city=1&country=1&sex=1&status=6&age_from=18&age_to=18&birth_day=1&access_token=5d345c872b24a247316ed25791ec4be02d469587eadab98f6ec9e0dab170ce39cf2f588895544483a2&v=5.52[/url] with MIME type application/json. See [url]https://www.chromestatus.com/feature/5629709824032768[/url] for more details.
sendRequest @ index.html:28