Reverse Geocode Callback

Using a callback to return the geocode results

HTML

<script src="http://maps.google.com/maps/api/js?sensor=false&amp;.js"></script>
<input type="textbox" value="40.730885,-73.997383" id="latlng" />
<input type="button" value="Reverse Geocode" />

<div id="display"></div>

JavaScript

$('input[type="button"]').click(function(){
    doGeocode(myCallBack);
});

function doGeocode(callback) {
    var latlngStr = $('input[type="textbox"]').val().split(",", 2);
    var lat = parseFloat(latlngStr[0]);
    var lng = parseFloat(latlngStr[1]);
    var latlng = new google.maps.LatLng(lat, lng);
    var geocoder = new google.maps.Geocoder();
    geocoder.geocode({
        'latLng': latlng
    }, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            if (results[1]) {
                callback.call(this, results);
            } else {
                alert("No results found");
            }
        } else {
            alert("Geocoder failed due to: " + status);
        }
    });
}

function myCallBack(data){
    console.log(data[1]);
  document.getElementById("display").innerHTML=data[1];
}