Created
December 13, 2015 15:36
-
-
Save osyoyu/ce8d7ab9cf0741742e6f to your computer and use it in GitHub Desktop.
xhr-promise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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