Last active
August 29, 2017 12:30
-
-
Save vishnusomanus/42c4a58cfb267211e1cf7b82d3b1cd50 to your computer and use it in GitHub Desktop.
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
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