This file contains hidden or 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
| // ajax(..) is some arbitrary Ajax function given by a library | |
| var response = ajax('https://example.com/api'); | |
| console.log(response); | |
| // `response` won't have the response |
This file contains hidden or 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
| ajax('https://example.com/api', function(response) { | |
| console.log(response); // `response` is now available | |
| }); |
This file contains hidden or 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
| // ajax(..) is some arbitrary Ajax function given by a library | |
| var response = ajax('https://example.com/api'); | |
| console.log(response); | |
| // `response` won't have the response |
This file contains hidden or 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
| ajax('https://example.com/api', function(response) { | |
| console.log(response); // `response` is now available | |
| }); |
This file contains hidden or 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
| console.log('asda'); |
This file contains hidden or 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
| // This is assuming that you're using jQuery | |
| jQuery.ajax({ | |
| url: 'https://api.example.com/endpoint', | |
| success: function(response) { | |
| // This is your callback. | |
| }, | |
| async: false // And this is a terrible idea | |
| }); |
This file contains hidden or 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
| function first() { | |
| console.log('first'); | |
| } | |
| function second() { | |
| console.log('second'); | |
| } | |
| function third() { | |
| console.log('third'); | |
| } | |
| first(); |
This file contains hidden or 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
| console.log('Hi'); | |
| setTimeout(function cb1() { | |
| console.log('cb1'); | |
| }, 5000); | |
| console.log('Bye'); |
This file contains hidden or 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
| setTimeout(myCallback, 1000); |
This file contains hidden or 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
| console.log('Hi'); | |
| setTimeout(function() { | |
| console.log('callback'); | |
| }, 0); | |
| console.log('Bye'); |
OlderNewer