title: Using Nonce with Ajax in WordPress Plugin
body: <p>I'm trying to use a nonce in a WordPress plugin. I've got a form that I want use the nonce on. </p>
  
  <p>In php: </p>
  
  <pre><code>function csf_enqueue() {
  
  //I have other scripts enqueued in htis function 
  wp_enqueue_script('my-ajax-handle', plugin_dir_url(__FILE__).'file-path', array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'google-maps'));
  
  $data = array(
      'ajax_url' =&gt; admin_url( 'admin-ajax.php' ),
      'my_nonce' =&gt; wp_create_nonce('myajax-nonce')
  );
  
  wp_localize_script('my-ajax-handle', 'the_ajax_script', $data );
  
  }
  
  add_action('wp_enqueue_scripts', 'csf_enqueue');
  add_action('wp_ajax_the_ajax_hook', 'the_action_function');
  add_action('wp_ajax_nopriv_the_ajax_hook', 'the_action_function');
  </code></pre>
  
  <p>In the jQuery file:</p>
  
  <pre><code>jQuery.post(the_ajax_script.ajaxurl, {my_nonce : the_ajax_script.my_nonce}, jQuery("#theForm").serialize() + "&amp;maxLat="+ csf_dcscore_crime_map_bounds[0] + "&amp;maxLong="+ csf_dcscore_crime_map_bounds[1] + "&amp;minLat="+ csf_dcscore_crime_map_bounds[2] + "&amp;minLong="+ csf_dcscore_crime_map_bounds[3],
                      function(response_from_the_action_function){
                          jQuery("#response_area").html(response_from_the_action_function);
                      });
  </code></pre>
  
  <p>Am I posting the nonce correctly in the jQuery?</p>
  
  <p>In php: </p>
  
  <pre><code>function the_action_function() {
     if( ! wp_verfiy_nonce( $nonce, 'myajax-nonce')) die ('Busted!');
  //function continues
  </code></pre>
  
  <p>Any suggestions? If I strip out all the code regarding the nonce, everything works fine. Any ideas as to why it's not working? Or how can I debug it? Thank you!</p>
  
  <p>Thank you.</p>