Skip to content

Instantly share code, notes, and snippets.

@osyoyu
Created December 13, 2015 15:36
Show Gist options
  • Save osyoyu/ce8d7ab9cf0741742e6f to your computer and use it in GitHub Desktop.
Save osyoyu/ce8d7ab9cf0741742e6f to your computer and use it in GitHub Desktop.
xhr-promise
"use strict";
(function () {
var getOsyoyuCom = new Promise(function (resolve, reject) {
var url = '/hoge.txt';
var request = new XMLHttpRequest();
request.open('GET', url, false);
request.onload = function () {
resolve(request.response);
};
request.send();
});
getOsyoyuCom.then(function (data) {
console.log(data);
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment