Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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