Skip to content

Instantly share code, notes, and snippets.

@garyc40
Created October 3, 2012 15:16
Show Gist options
  • Save garyc40/3827500 to your computer and use it in GitHub Desktop.
Save garyc40/3827500 to your computer and use it in GitHub Desktop.
WordPress ajax submit code
jQuery.post(
// see tip #1 for how we declare global javascript variables
MyAjax.ajaxurl,
{
// here we declare the parameters to send along with the request
// this means the following action hooks will be fired:
// wp_ajax_nopriv_myajax-submit and wp_ajax_myajax-submit
action : 'myajax-submit',
// other parameters can be added along with "action"
postID : MyAjax.postID
},
function( response ) {
alert( response );
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment