WordPress.org

Support

Support » Plugins and Hacks » Problem with admin-ajax.php adding '0' to the end of JSON response

Problem with admin-ajax.php adding '0' to the end of JSON response

  • I’m having a peculiar problem with admin-ajax.php where anything I send it, it will return a ‘0’ at the end of the response content. For exmample, I have in my code this:

    function myAjaxCallback() {
        print 1;
    }
    add_action('wp_ajax_myAjax', 'myAjaxCallback');

    The javascript side is like this:

    jQuery.post(ajaxurl, {action:'myAjax'}, function(result) {
        console.log(result);
    }

    In my debug message I would expect just ‘1’, but I’m getting ’10’. It happens no matter what I print in the ajax callback function. I have no idea what’s doing this, so any help would be appreciated.

    Should also note that this is in a plugin I’m working on, and it’s happening on both the post.php page and widgets.php page.

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Problem with admin-ajax.php adding '0' to the end of JSON response’ is closed to new replies.
Skip to toolbar