Please try this and inform me what you got in the console. and sure console.log
the type
add_action( 'wp_ajax_comment_meta_update_vote', 'comment_meta_update_vote' );
function comment_meta_update_vote( ) {
check_ajax_referer( 'upvote_nonce' );
$comment_id = $_POST['comment_id'];
$vote_score = get_comment_meta($comment_id , 'vote', true);
$vote_score++;
$updated = update_comment_meta($comment_id , 'vote', $vote_score );
if($updated){
$msg = 'success';
}else{
$msg = 'failed';
}
$response = array('type' => $msg);
wp_json_encode( $response );
die();
}
Related Posts:
- Does the functions.php file ever get called during an AJAX call? Debug AJAX
- Changing the entire control choices using wp.customize with JavaScript
- pass wordpress template directory into ajax url call
- What is the preferred way to add custom javascript files to the site?
- pass object/JSON to wp_localize_script
- Any alternate TinyMCE4 themes / subthemes?
- Is there a way to set the order of wp_footer hooked functions?
- Google Maps not displaying in wordpress using Google Maps Javascript API
- redirect does not work in ajax function
- Trigger Customizer saving process with Javascript only
- Custom Comments – Parent / Nested Reply
- Why is styling comments so complex?
- Comment form not display properly?
- What is the best practice for customizing a plugin’s JavaScript/jQuery?
- Add a preview to a WordPress Control Panel
- How to Auto Approve Comments on a Specific Page?
- comment_form() generates the wrong action url
- Customize comment list markup
- How to Change CSS Variable value in Theme Customizer Live Preview
- how to pull wordpress post comments to a external page
- Separated Comment from Post
- Remove “a href” from wp_list_comments()
- WordPress Customizer Control with React
- How WordPress converts URL to $query_string
- How to hook CSS file according to theme selection in the customizer section
- using wordpress without javascript
- How to Globally Use wp_localize_script() Ajax URL
- How to get comment meta values by post ID
- Compact pingback list with favicons
- How to change i18n/l10n of #reply-title? (Old title: Comment reply link not working)
- How to remove comment link title attribute?
- Using AJAX in wordpress theme
- Comment entry screen shows even though “Allow Comments” is unchecked
- Trying to implement Ajax comments in WordPress, getting WP error
- jQuery not available to other scripts
- Using an if statement in the theme customizer page
- Single page site with history.js
- Jetpack Comments with fall-back
- Use second time navigation.js in underscores [closed]
- How to: JQuery multiple wordpress media uploader buttons in the same options page?
- Retrieve localised value
- AJAXIFY WordPress Theme Frontend menu
- Theme Customizer not loading JS for live preview
- Trackbacks not displaying
- Nested comments in WordPress theme
- My jQuery is enqueued properly. So why isn’t it working?
- Enqueued JavaScript is not working
- Comment status shows ‘closed’ in db, but it shows ‘open’ when i echo it
- How to register and enqueue JavaScript files without breaking plugin dependencies?
- wp_enqueue_script not working?
- How can I wrap all blog posts image with
- White screen when attaching css to function.php
- Why does admin-ajax load slow and what are ways to speed it up?
- Why WordPress AJAX returns undefined however it works fine when I add static url instead of dynamic function?
- How to use ajax in wordpress and sending the data without refreshing ?
- Issue on Accessing To Ajax Enqeued File to Pass to URL for Ajax Call
- theme-independent CSS/JS files
- How to enable Disqus comments in a WordPress theme I’m creating from scratch? [closed]
- Javascript development in Custom Themes
- Ajax call returns 0 when add_action is inside a class in functions.php
- add jquery file if a certain page is included
- Retrieve WordPress’ the_content() with jQuery
- WordPress Comment spam issue
- Pagination don’t work with active filters
- enqueuing external and internal js and css in wordpress did not work with owl.js animate.css
- Woocommerce AJAX filters option loading spiner – problem on mobile device
- how use ajax to custom page template
- How to diagnose wp-env environment problem
- Why excerpt hook not working inside ajax function?
- Theme functions don’t work as expected in partial included via get_template_part() after custom query using Ajax [duplicate]
- How to load jQuery with Ajax in WP version 5.3.2?
- How to enqueue scripts properly with ES6 webpack?
- use a single nonce in three different nonce field
- Infinite scroll without plugin using ajax
- change background image on scroll
- Does any JavaScript file load automatically for index.php file?
- wp_kses allow checkbox class and checked
- Modify comments_popup_link output
- WordPress Ajax Spitting out a page as a response?
- Using Customizer value in an external PHP file inside a theme
- Woocommerce Theme Reviews / Comments
- How would I get this to work – send to post from thick box
- How to avoid Ajax in wordpress theme in making mulitple request?
- child comments not displaying as nested
- How can I fix the even/odd child classes comments so that the comments are unaffected by the top-level even/odd?
- wp_update_comment not working
- Theme customizer live preview JS- Trying to bind to an html image url without luck
- Set start page depending on screen width [closed]
- wp_deregister_script was called incorrectly
- Paginated WP_Query doesn’t return 404’s, even when posts don’t exist
- Using wp_enqueue_script with social media buttons?
- How to convert that page to a wordpress template? [closed]
- Allow access to stand-alone php file WordPress
- can’t add EVENT LISTENER to a element
- What is The Best Way to Make Parallax header effect for wordpress theme ?? pure CSS or using JavaScript? [closed]
- How can i move my product name & price from below thumbnail to be the rollover content in Avada & Woocommerce?
- Which function(s) to build a paged HTML table
- Is there a Function so that the author of the comment can delete his own comment?
- jQuery Snippet Not Working on WordPress Site [closed]
- Is there any halfway decent documentation on the wp.media JS class?