How to asssign a value to a global variable from ajax output
<p>I have this code:</p>

<pre><code>var temp_f;

jQuery(document).ready(function($) {
    $.ajax({
        url: "http://api.wunderground.com/api/a5fb7d26008efccb/geolookup/conditions/forecast/q/India/Dhule.json",
        dataType: "jsonp",
        success: function(parsed_json) {
            var location = parsed_json['location']['city'];
            temp_f = parsed_json['current_observation']['temp_f'];
            alert("Current temperature in " + location + " is: " + h);
        }
    });
});

function get(){
    alert(temp_f);  
}   
</code></pre>

<p>I want to store value of local variable <code>temp_f</code> in jQuery section into global variable <code>temp_f</code> declared at the beginning of script but when I am running this code it is showing value of global <code>temp_f</code> as <code>undefined</code>.</p>

<p>Can anyone point out the mistake I am making or suggest any other way to do so?</p>