Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. function count_up(obj) {
  2. var len = obj.value.length;
  3. $("span#numbers").text(len);
  4. };
  5.  
  6. function loadFile() {
  7. return new Promise((resolve, reject) => {
  8. try{
  9. //Function about loading file
  10. //...
  11. resolve(obj);
  12. } catch (e) {
  13. reject(e);
  14. }
  15. });
  16. };
  17.  
  18. loadFile() //Will do count_up after the text is loaded
  19. .then(function(obj){
  20. count_up(obj);
  21. })
  22. .catch((reason) => {
  23. console.log('Handle rejected promise ('+reason+') here.');
  24. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement