all
In my theme there is a notification at top. After user login he can see the notification update. when click on notification i want to make change in database alert field value 0 to 1.
My ajax call in theme
$("#notifications-button").click(function() {
$.ajax({
type : 'POST',
url: "http://localhost/rupp/wp-admin/admin-ajax.php",
data:{action:'MyAjaxFunction'},
success : function(data){
$('.message-count').hide();
},
});
});
and in function.php file
add_action('wp_ajax_MyAjaxFunction','MyAjaxFunction');
function MyAjaxFunction()
{
global $wpdb;
echo (int)$user_ID;
$wpdb->update( $wpdb->wp_frm_items,
array( 'alerts' => 1)
);
}
but it not make any changes in alert fields in db. is that right way to call theme function using ajax?
$wpdb->update()method work when you're not calling it via ajax? – sanchothefat Mar 6 '12 at 10:22