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?
- theme path in javascript file
- pass object/JSON to wp_localize_script
- Solutions for generating dynamic javascript / CSS
- Enable Submit Comment Without Page Reload (Using Ajax)?
- How bad is it if I write AJAX functions using wp-load.php?
- Proper, exhaustive documentation for wp.editor etc
- Any alternate TinyMCE4 themes / subthemes?
- Nested comments ignored for max per page in wordpress
- 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
- Modifying JS files in Child-theme
- Separated Comment from Post
- Remove “a href” from wp_list_comments()
- Whats the safest way to output custom JavaScript and Css code entered by the admin in the Theme Settings?
- WordPress Customizer Control with React
- How to call wp_list_comments() with callback outside the loop
- Can’t access WordPress functions in file called via Ajax?
- How to configure wordpress to work with Vuejs with SSR and without hashbang
- How WordPress converts URL to $query_string
- How to hook CSS file according to theme selection in the customizer section
- How to correctly add JQuery in a WP theme?
- 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
- Including Javascript options
- trying to use wp_handle_upload with ajax
- 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
- JavaScript Change focus to password field login page being reset
- jQuery not available to other scripts
- How to make Isotope and WordPress work together?
- Using an if statement in the theme customizer page
- Single page site with history.js
- Jetpack Comments with fall-back
- How to add material design css in wordpress and woocommerce
- JS innerhtml changing style when using AJAX
- Use second time navigation.js in underscores [closed]
- WP_Comment_Query – Get comments and answers separately
- Theme Javascript.php Overwritten Nightly [closed]
- How to: JQuery multiple wordpress media uploader buttons in the same options page?
- How to get javascript slider to work! [closed]
- Retrieve localised value
- AJAXIFY WordPress Theme Frontend menu
- Theme Customizer not loading JS for live preview
- Post thumbnail to append post content via ajax click event
- Trackbacks not displaying
- Nested comments in WordPress theme
- Would to use AJAX to get an option from the database and use it in a jquery setup or is there an alternative to consider?
- 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?
- ajax response -1 in wordpress theme
- How can I wrap all blog posts image with
- White screen when attaching css to function.php
- WordPress theme resource won’t load over VPN
- 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
- Difference between “comment_form_default_fields” AND “comment_form_fields”
- How to enable Disqus comments in a WordPress theme I’m creating from scratch? [closed]
- How to add custom class to get_avatar()
- Javascript development in Custom Themes
- Same comments on all posts
- 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
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- AJAX call fails when sending JSON but works with URL style string
- WordPress comments title
- 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
- getBoundingClientRect() showing different values on load vs scroll
- wordpress script_loader_tag in function.php
- how use ajax to custom page template