I'm developing a simple wordpress wordpress plugin and seeking to make use of AJAX, however i always get in ajax response.

<script type="text/javascript" >
jQuery(document).ready(function($) {

var data = {
    action: 'my_action',
    whatever: '1234'

jQuery.post("http://localhost/taichi/wp-admin/admin-ajax.php", data,   function(response) {
add_action('wp_ajax_my_action', 'my_action_callback');
add_action( 'wp_ajax_nopriv_my_action', 'my_action_callback' ); 

function my_action_callback() {

echo "test";


what shall we be held doing wrong?

Error Return Values

When the AJAX request fails once the request url is wordpress-admin/admin-ajax.php, it'll return either -1 or 0 with respect to the reason it unsuccessful.

Read this


admin-ajax always return default '0' as output.so when you notifying response you'll 0 only.using die() in callback function will terminate that.

You need to place the add_action in the complete bottom of the file otherwise it will not discover the callback function