Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to make an AJAX call for a plugin.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
    '<?php admin_url('admin-ajax.php'); ?>',
        action : 'AAA'
    function( response ) {
        alert( "[[[[" + response + "]]]]" );

The ajax call is working fine.

add_action( 'wp_ajax_nopriv_AAA', 'fAAA' );
add_action( 'wp_ajax_AAA', 'fAAA' );

function fAAA(){
      echo "123";

For some reason my fAAA is not getting called.

I used var_dump( $wp_filter['wp_ajax_nopriv_AAA'] ); to check the actions. * in the plugin, it showed that the action is added * when i looked in admin-ajax.php, the action is not there.

Any help?

share|improve this question

2 Answers 2

Aside from @Tareq answer (which is your main problem), you should

  • wp_register_script and the wp_enqueue_script
  • load your local copy of jQuery instead of the one from Google CDN
  • localize your script using wp_localize_script
share|improve this answer

You didn't echo admin_url('admin-ajax.php')

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.