var script = document.createElement('SCRIPT');
script.src = "https://api.vk.com/method/users.get?
user_ids=210700286&fields=bdate&v=5.101&callback=callbackFunc";
document.getElementsByTagName("head")[0].appendChild(script);
function callbackFunc(result) {
alert(result.response[0].first_name)
}
function httpGet(url) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onload = function () {
if (this.status == 200) {
resolve(this.response);
} else {
var error = new Error(this.statusText);
error.code = this.status;
reject(error);
}
};
xhr.onerror = function () {
reject(new Error("Network Error"));
};
xhr.send();
});
}
httpGet("/article/promise/user.json")
.then(
response => console.log(`Fulfilled: ${response}`),
error => console.log(`Rejected: ${error}`)
);
console.log('не лезь');