Skip to content
Advertisement

Ajax click function is not working in WordPress functions

I would appreciate some help. I am trying to create a save bookmark plugin through wordpress functions file (all code in one place). The problem is I am unable get the ajax, jquery to work I am not sure what part of it is not working. You click on link and it’ll call ajax and then php where it’ll save the post_id, user_id into the database.

Here’s the code (funtions.php):

JavaScript

Can someone please tell me what is it that keeps going wrong?

Advertisement

Answer

if you are using in admin area then use “add_action(‘admin_footer’, ‘bookmark_add’);” for frontend “add_action(‘wp_footer’, ‘bookmark_add’); “

also check your action.

JavaScript
JavaScript

you can check for more info https://codex.wordpress.org/AJAX_in_Plugins

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement