-
-
Save jsakhil/27f14ba1ea0a9dbab57b482d71f94298 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
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