I am trying to implement an answer given in the following question: How do I return the response from an asynchronous call?
Scroll down to the answer by Hemant Bavle (currently 62 votes). This is exactly what I am trying to implement, but still no luck. Here is my attempt (I've omitted the ajaxSetup() and fail() for brevity):
function isGoodPIN(pin) {
    var result;
    var cURL = "server/checkPIN?pin=" + pin;
    function setResult(ajaxResult) {
        result = ajaxResult; // <--------- true here...
    }
    var ajaxResponse = $.get(cURL, function (data) {
        // data is "OK" here...
        setResult(data == "OK" ? true : false);
    });
    return result; //<--------- undefined here
}
Is this a scope problem because result in setResult() is local to setResult() and not visible outside of it? If so, what is the solution to this problem?
 
     
    