Skip to content

Instantly share code, notes, and snippets.

@vishnusomanus
Last active August 29, 2017 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vishnusomanus/42c4a58cfb267211e1cf7b82d3b1cd50 to your computer and use it in GitHub Desktop.
Save vishnusomanus/42c4a58cfb267211e1cf7b82d3b1cd50 to your computer and use it in GitHub Desktop.
var data = {
action: 'image_color',
id: 1234
}
//jQuery
jQuery.ajax(
{
url: " http://domain.com/wp-admin/admin-ajax.php",
type: "POST",
data: data,
success: function (result) {
alert('success');
}
});
//in function.php
add_action( 'wp_ajax_function_name', 'function_name' );
add_action( 'wp_ajax_nopriv_function_name', 'function_name' );
function function_name() {
echo "string";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment