Below is the code for the AJAX File. alert(cont)
is given the correct result but the problem is with the response. I am just getting error as the response.
function updateRadioButton(rating,pid){
var cont = rating + '-' + pid;
alert(cont);
jQuery.ajax({
type: 'POST',
url: TihomAjax.ajaxurl,
data: {"action": "tihom_rating_action", "contd":cont},
success: function(data){
if (data.success) {
alert("success");
} else {
alert("error");
}
}
});
}
Code for the tihom_rating_action function
and other hooks in Wordpress are
wp_enqueue_script('tihom_ajax', plugins_url( '/js/tihom_ajax.js' , __FILE__ ) , array( 'jquery' ));
wp_localize_script( 'tihom_ajax', 'TihomAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php') ));
function tihom_rating_action() {
echo "hello";
wp_die();
}
add_action( 'wp_ajax_my_action', 'tihom_rating_action' );
add_action( 'wp_ajax_nopriv_my_action', 'tihom_rating_action' );