Why does WordPress add 0 (zero) to an Ajax response?

The default response from admin-ajax.php is,

die( '0' );

…by adding your own wp_die() or exit() or die() after returning your desired content prevents the default response from admin-ajax.php being returned as well.

It also generally means that your ajax call has succeeded.

Ultimately, to answer your question, it’s meant to work this way. What you are doing by exiting after returning your content is the right thing to do.

Leave a Comment