title: How to pass variables values from .post response to PHP
body: <p>I'm trying to run Geocode from Google Maps Api with my wp-admin plugin. I have my own post type where is input for address of place, and jQuery code watching for click on div.
  So that's my code:<br>
  <strong>Plugin Code [PHP]:</strong>  </p>
  
  <pre><code>add_action( 'wp_ajax_generate_geocode', array($this, 'generate_geocode') );
  [...]
  //here is my test function that is waiting for response and doing something.
  public function generate_geocode() {
  
      print_r($_POST);
      die();
  }
  </code></pre>
  
  <p><strong>AJAX Code [JS with jQuery]:</strong>  </p>
  
  <pre><code> jQuery(document).ready(function() {
  var lat = '';
  var lng = '';
  
  jQuery('#generate-geocode').on('click', function() {
      var address = jQuery('#address').val();
      // alert(address);
      var geocoder = new google.maps.Geocoder();
      geocoder.geocode({address: address}, function(results, status) {
          //alert(status);
          if (status == google.maps.GeocoderStatus.OK) {
              lat = results[0].geometry.location.lat();
              lng = results[0].geometry.location.lng();
              alert(lat + ' ' + lng);
          }
      });
      data = {
          action: 'generate_geocode',
          lat: lat,
          lng: lng
      };
      jQuery.post(ajaxurl, data, function(response) {
          alert(response); 
      });
  });
  });
  </code></pre>
  
  <p>My problem is that I don't know how to pass lat and lng variables or it's values (value of results[0].geometry.location.lat() and results[0].geometry.location.lng()) to my PHP code. So for a now I have in my alert:  </p>
  
  <pre><code>Array
  (
   [action] =&gt; generate_geocode
   [lat] =&gt;
   [lng] =&gt;
  )
  </code></pre>
  
  <p>Can You tell me how to pass that values? And maybe there is better way? :)</p>