Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function count_up(obj) {
- var len = obj.value.length;
- $("span#numbers").text(len);
- };
- function loadFile() {
- return new Promise((resolve, reject) => {
- try{
- //Function about loading file
- //...
- resolve(obj);
- } catch (e) {
- reject(e);
- }
- });
- };
- loadFile() //Will do count_up after the text is loaded
- .then(function(obj){
- count_up(obj);
- })
- .catch((reason) => {
- console.log('Handle rejected promise ('+reason+') here.');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement