Skip to content

Instantly share code, notes, and snippets.

@ypsilon-p
Created November 7, 2018 15:33
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 ypsilon-p/60bdb771eebceb75c7ecb1cde962f48e to your computer and use it in GitHub Desktop.
Save ypsilon-p/60bdb771eebceb75c7ecb1cde962f48e to your computer and use it in GitHub Desktop.
jQuery.post(
my_foobar_client.ajaxurl,
{
'action': 'foobar',
'foobar_id': 123
},
function(response) {
console.log('The server responded: ', response);
}
);
<?php
/*
Plugin Name: Formscript
Description: includes form xyz.
Author: Yannik Preiß
*/
add_action( 'wp_ajax_foobar', 'my_ajax_foobar_handler' );
function my_ajax_foobar_handler() {
// Make your response and echo it.
// Don't forget to stop execution afterward.
wp_die();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment