I've got AJAX which gets timezone information in a function and I want it to return the result.
I now understand that AJAX is asynchronous so I need to have a callback function. I've looked at examples but I can't wrap my head around it.... I'm not sure where the arguments in my getTimezone() function go if I change that to just take a callback function.
Any help would be appreciated, here's the code:
ztimezone=getTimezone(lat,lng);
function getTimezone( tlat,  tlong) {
                 url = "https://maps.googleapis.com/maps/api/timezone/json?location="+tlat+","+tlong+"×tamp=1331161200&key=******";  
                 $.ajax({  
                 url: url,  
                 type: "GET",  
                 crossDomain: true,  
                 dataType: 'json',  
                 success: function (data) {  
                    alert(data.timeZoneId); 
                    zdata=((data.rawOffset/60)/60);
                 },  
                 error: function (xhr, err) {  
                     alert(xhr.responseText);  
                 }  
             });
return zdata;                
}
 
    