Unsure why variable is undefined. Possible scope issue?
<p>If you look at the function below, on line 11 where it <code>alert(template);</code>. It prints <code>undefined</code>. If I <code>alert(template);</code> inside the ajax success callback, it prints no problem. Since template is defined at the top of the function, shouldn't this be global through out the entire function? Can someone assist me with this?</p>

<pre><code>function load_template(path, data, callback){
    var template;

    $.ajax({
        url: path,
        success: function(uncompiled_template){
            template = Handlebars.compile(uncompiled_template);
        }
    });

    alert(template);    

    if(callback){
        callback(template, data);
    }else{
        return template(data);
    }
}
</code></pre>
