Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var p = new Promise(function(resolve, reject) {
- var xmlhttp = new XMLHttpRequest();
- xmlhttp.onreadystatechange = function() {
- if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
- myFunction(xmlhttp);
- }
- };
- xmlhttp.open("GET", "cd_catalog.xml", true);
- xmlhttp.send();
- function myFunction(xml) {
- var xmlDoc = xml.responseXML;
- ip = xmlDoc.getElementsByTagName("IP")[0];
- returnip = ip.childNodes[0];
- return returnip;
- }
- alert(myFunction());
- b = 40;
- if(ping == "194.72.68.35") {
- resolve('Success!');
- }
- else {
- reject('Failure!');
- }
- });
- p.then(function() {
- console.log("This is awesome");
- }).catch(function() {
- console.log("what the hell!");
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement