mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
21 lines
480 B
JavaScript
21 lines
480 B
JavaScript
function XHR(url) {
|
|
return new Promise(function(resolve, reject) {
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('GET', url);
|
|
|
|
xhr.onload = function() {
|
|
if (xhr.status === 200) {
|
|
resolve(xhr.responseText);
|
|
} else {
|
|
reject(new Error(xhr.statusText));
|
|
}
|
|
};
|
|
|
|
xhr.onerror = function() {
|
|
reject(new Error("Network Error"));
|
|
};
|
|
|
|
xhr.send();
|
|
});
|
|
}
|