title: How to fetch multiple return values from a JavaScript function
body: <p>I have JavaScript function call to <code>changeMapLocation</code> function where in it I want to return the variables <code>lat</code> and <code>long1</code>. I have some problem in code to return those two variables and alert in function call. </p>
  
  <pre><code>var sample = changeMapLocation(state);
  alert(sample.lat1);
  alert(sample.lat2); 
  
  function changeMapLocation(state) {
     var addressval=state;
     var address;
     var url;
     var googleUrl= "http://maps.google.com/maps/api/geocode/json?";
     var  sensor  = "&amp;sensor=false";
  
     if(addressval != null &amp;&amp; addressval !="" &amp;&amp; addressval.length!=0) {
  
        address = "address="+encodeURIComponent(addressval);
  
        $.ajax({
          url:googleUrl+address+sensor,
          type:"POST",
          dataType:"json",
          success:function(longlatJson) {
             var jsonObj = JSON.parse(JSON.stringify(longlatJson));
             var lat = jsonObj.results[0].geometry.location.lat;
             var long1 = jsonObj.results[0].geometry.location.lng;
             alert(lat);
             alert(long1);
             //var latlng = new google.maps.LatLng(lat,long1);
             //alert(latlng);
          },
          error:function(){alert("unable to conect to google server");}
        });
     }
     return(lat1:lat,lat2:long1); 
  }
  </code></pre>