Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var req = new XMLHttpRequest();
- req.open('GET', '/path/to/my/thing', true); // true means it's asynchronous, you want that
- req.responseType = 'json';
- req.send(null); // because you don't have data to send, you're just requesting
- function shit_broke() {
- }
- req.onload = function() {
- if (req.status==200) {
- console.log(req.response);
- _this.importBot(req.response);
- // do something when it's chill
- } else {
- shit_broke();
- // do something when it's not chill, and its probably your server
- // because the status code is not 200
- }
- };
- req.onerror = function() {
- shit_broke();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement