Answer the question
In order to leave comments, you need to log in
What needs to be fixed so that the cross domain error does not appear?
Script for getting the date of registration in a contact
function dataReg(e){
let r = new XMLHttpRequest();
r.open('GET', 'https://vk.com/foaf.php?id=' + e, true);
r.addEventListener("readystatechange", () => {
if (r.readyState === 4 && r.status === 200) {
var xd = (r.responseText.match(/ya:created dc:date="(.+)T(.+)"/i)||[]), ad, div;
if (xd) {
ad = xd[1].split('-');
div = document.createElement ('div');
div.className = 'clear_fix profile_info_row';
console.info(ad)
}
}
});
r.send()
}
dataReg(1);
Access to XMLHttpRequest at 'https://vk.com/foaf.php?id=50781636' from origin 'https://vk-get.ru' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Answer the question
In order to leave comments, you need to log in
Years passed, people never learned how to copy the text of the error in Google.
This is CORS. This cannot be bypassed on the client. Only if you set your "proxy" server
VKontakte did not give such permission, that's all.
Hypothetically, you can get permission from VKontakte by registering as a developer, creating a new application, obtaining an API key and specifying the domain from which requests will come from the browser. Almost at some stage, you may still need your own server
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question