I'm trying to add a nonce to my plugin's Ajax. I'm not sure why I'm getting this error:
Fatal error: Call to undefined function wp_create_nonce()
In my php file :
wp_localize_script('my-ajax-handle', 'the_ajax_script', array('ajaxurl'=> admin_url('admin-ajax.php'), 'my_nonce' => wp_create_nonce('myajax-nonce'))); In js file:
jQuery.post(the_ajax_script.ajaxurl, {my_nonce : the_ajax_script.my_nonce}, jQuery("#theForm").serialize() + "&maxLat="+ map_bounds[0] + "&maxLong="+ map_bounds[1] + "&minLat="+ map_bounds[2] + "&minLong="+ map_bounds[3], function(response_from_the_action_function){ jQuery("#response_area").html(response_from_the_action_function); }); Any suggestions on how to solve this?
Thank you.