I'm using ajax in wordpress. Here is my ajax code :
var name = "Toto";
$.ajax({
url : ajaxurl,
type : 'post',
data : {
'action' : 'test_action',
'data' : {
'name' : name,
}
},
success : function(response){
alert(response);
},
error : function(){
alert('error');
}
});
My PHP code
add_action("wp_ajax_test_action", "_test_function");
function _test_function(){
wp_localize_script( 'edit-taxonomy' , 'ajax_object' , array('ajaxurl' => admin_url('admin-ajax.php')));
die('success');
}
then I inspected it on browser and I get :
I get an alert with '0' value (as I did in success case). Then I realize that it doesn't call _test_function function (it should return 'success'). I think it's port problem because with other similar code, port value is 80 and it works, but I don't understand why is it using another port, and how to fix it.
