Created
September 10, 2014 19:30
-
-
Save tehnrd/48ec15fbd75cfa5077ae to your computer and use it in GitHub Desktop.
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
// See the question in the callback function | |
function getContacts() { | |
var accountId; | |
//Some code that dynamically sets accountId would be here | |
$.get("/contacts.json?accountId=" + accountId, function( data ) { //This is an asynchronous callback function | |
/*This inside an anonymous function executing asynchronously in a seperate context from when getContacts() | |
was originally called but it still has the ability to read the value in the 'accountId' var. | |
Why? What is this commonly refered to.*/ | |
console.log('I see you ' + accountId); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment