I had created the ajax request
add_action('wp_ajax_test_action', 'test_action');
it works fine until some point
(Maybe i installed some plugin, but i had tried uninstall it but cant solve it)
So i try to add
add_action('wp_ajax_nopriv_test_action', 'test_action');
the request work again, but I don't understand
wp_ajax_nopriv suppose to work for the user not logged in
but i am a logged in user, I tried to logged out then login again, but still need to add "wp_ajax_nopriv" to make it work.
my js code:
//test ajax
$('button#test').on('click', function(e){
e.preventDefault();
console.log('click');
$.ajax({
url: $ajax_url,
type: 'POST',
data: {
action: 'test_action',
value: "send"
},
success: function(data){
console.log( data);
},
error: function(data){
console.log('error');
}
});
});