Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- PHP
- */
- add_action( 'wp_ajax_bookmark', 'handle_bookmark' );
- add_action( 'wp_ajax_nopriv_bookmark', 'handle_bookmark');
- function handle_bookmark() {
- $user = $_REQUEST["user"];
- $postID = $_REQUEST["postID"];
- $res = update_field($selector, $value, $post_id);
- if($res):
- echo json_encode(array(
- "success" => true,
- "message" => "message message message"
- ));
- else:
- echo json_encode(array(
- "success" => false,
- "message" => "message message message"
- ));
- endif;
- exit();
- }
- /*
- jQuery
- */
- $.ajax({
- method: "POST",
- url: "url de ajax de wordpress",
- data: { userID: "John", postID: "Boston" }
- })
- .done(function( msg ) {
- console.log( "Data Saved: " + msg );
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement