Created
April 11, 2016 19:53
-
-
Save JayWood/6366b64a194004a8e64c63e9e5515719 to your computer and use it in GitHub Desktop.
ajax example
This file contains 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
jQuery.post( ajaxurl, jQuery( '#theForm' ).seraizlize(), function( response ) { | |
/** | |
* At this point, response should equal a json encoded response | |
* SO if you're doing something like this: | |
* | |
* wp_send_json_success( array( 'some_key' => 'some value' ) ) | |
* you can access it like so: | |
*/ | |
if ( response.success ) { | |
// Success data is stored within response.data | |
alert( response.data.some_key ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment