Skip to content

Instantly share code, notes, and snippets.

@johnmontfx
Created March 19, 2016 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnmontfx/719658db79be0780fab5 to your computer and use it in GitHub Desktop.
Save johnmontfx/719658db79be0780fab5 to your computer and use it in GitHub Desktop.
Testing the wc-ajax function
add_action( 'wp_ajax_my_ajax_function_', 'my_ajax_function' );
function my_ajax_function() {
$mystuff = $_POST['stuff'];
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
set_transient('fx_mystuff' , $mystuff, '0');
}
die();
}
===================================
In the html
jQuery.ajax({
url : fxmedia.ajax_url,
type : 'post',
data : {
action : 'my_ajax_function',
security : '{{wp_nonce}}',
stuff : stuff
},
success : function( response ) {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment