All
In my application there is notification system, when user click on that icon I want to make ajax call. The problem id it works fine for admin user (Debug : 200 ok), but not for subscriber user (Debug : 301 moved permanently).
Ajax call
$("#notifications-button").click(function() {
$.ajax({
type : 'POST',
url: '<?php echo get_option('siteurl') . '/wp-admin/admin-ajax.php' ?>',
data:'action=my_special_ajax_call&value=1',
success : function(data){
$('.message-count').hide();
},
});
});
Function
function implement_ajax() {
if(isset($_POST['value']))
{
global $wpdb, $user_ID;
$wpdb->query( $wpdb->prepare("UPDATE wp_frm_items SET alerts_flag = 0 WHERE user_id = '". (int)$user_ID ."'" ));
}
}
add_action('wp_ajax_my_special_ajax_call', 'implement_ajax');
add_action('wp_ajax_nopriv_my_special_ajax_call', 'implement_ajax');//for users that are not logged in.
I do not able to get why this not working for subscriber? Is there anything wrong in code?
Thanks In Advance !
admin_url('admin-ajax.php')rather thanget_option('siteurl') . '/wp-admin/admin-ajax.php'.– Stephen Harris Mar 9 '12 at 10:39