Skip to content

Instantly share code, notes, and snippets.

@kjohnson
Last active August 29, 2015 14:27
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 kjohnson/ff7e5b45b5d8e9305ae1 to your computer and use it in GitHub Desktop.
Save kjohnson/ff7e5b45b5d8e9305ae1 to your computer and use it in GitHub Desktop.
CONNECTING THE DOTS WITH WP_AJAX
<?php
add_action( 'wp_ajax_my_action', 'kbj_my_action' );
function kbj_my_action() {
echo json_encode( array( 'message' => 'Message received!' ) );
wp_die(); // this is required to terminate immediately and return a proper response
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment