Created
November 15, 2016 14:56
-
-
Save mdix/740bc6a89b139c86865d801dc19cb1a8 to your computer and use it in GitHub Desktop.
XHR no connection wrapper
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
var req = new XMLHttpRequest(); | |
req.open("post", 'https://jquery.com', true); | |
req.onreadystatechange = function receiveResponse() { | |
console.log('readyState: ', this.readyState); | |
console.log('status: ', this.status); | |
console.log('response: ', this.response.length); | |
if (this.readyState == 4) { | |
if (this.status === 0 && this.response.length === 0) { | |
return console.log('NO CON') | |
} else { | |
console.log("We go a response"); | |
} | |
} | |
}; | |
req.send(); | |
req = null; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment