How can I return a variable from a $.getJSON function I want to return StudentId to use elsewhere outside of the scope of the $.getJSON() j.getJSON(url, data, function(result) { var studentId = result.Something; }); //use studentId here I would imagine this has to do with scoping, but it doesn't seem to work the same way c# does Solution: Yeah, my previous answer does not work because I didn't pay any attention to your code. :) The problem is that the anonymous function is a callback function - i.e. getJSON is