Last active
August 29, 2015 14:11
-
-
Save barrykooij/be7bd2dd9219104a41ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo '<input type="hidden" name="bk-ajax-nonce" id="bk-ajax-nonce" value="' . wp_create_nonce( 'bk-ajax-nonce' ) . '" />'; | |
?> | |
<script type="text/javascript"> | |
jQuery( document ).ready( function ( $ ) { | |
var data = { | |
action: 'my_action', | |
security: $( '#bk-ajax-nonce' ).val() | |
}; | |
$.post( ajaxurl, data, function ( response ) { | |
alert( "Response: " + response ); | |
} ); | |
} ); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment