Advertisement
Guest User

Untitled

a guest
May 12th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. var p = new Promise(function(resolve, reject) {
  2. var xmlhttp = new XMLHttpRequest();
  3. xmlhttp.onreadystatechange = function() {
  4. if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  5. myFunction(xmlhttp);
  6. }
  7. };
  8. xmlhttp.open("GET", "cd_catalog.xml", true);
  9. xmlhttp.send();
  10.  
  11. function myFunction(xml) {
  12. var xmlDoc = xml.responseXML;
  13. ip = xmlDoc.getElementsByTagName("IP")[0];
  14. returnip = ip.childNodes[0];
  15. return returnip;
  16. }
  17. alert(myFunction());
  18. b = 40;
  19.  
  20. if(ping == "194.72.68.35") {
  21. resolve('Success!');
  22. }
  23. else {
  24. reject('Failure!');
  25. }
  26. });
  27.  
  28. p.then(function() {
  29. console.log("This is awesome");
  30. }).catch(function() {
  31. console.log("what the hell!");
  32. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement