title: Why does Wordpress ajax die('0')
body: <p>I added the following to my functions.php file:</p>
  
  <pre><code>add_action('wp_ajax_send_email', 'send_email_callback');
  add_action('wp_ajax_nopriv_send_email', 'send_email_callback');
  </code></pre>
  
  <p>So i added the following callback function:</p>
  
  <pre><code>send_email_callback()
  {
  //do some processing
   echo json_encode(array('response'=&gt;'Ya man it worked.'));
  //return control back to *-ajax.php
  }
  </code></pre>
  
  <p>This is what is returned to my javascript : </p>
  
  <pre><code>{"response":"Ya man it worked."}0
  </code></pre>
  
  <p>So ofcourse when it reaches the  $.parseJSON( msg ) line I get Uncaught SyntaxError: Unexpected number.</p>
  
  <pre><code>  var request = $.ajax({
              url: "/wp-admin/admin-ajax.php",
              method: "POST",
              data: { action : 'send_email', P : container },
              dataType: "html"
          });
  
          request.done(function( msg ) {
  
             var obj = $.parseJSON( msg );
              console.log(obj.response);
  
          });
  
          request.fail(function( jqXHR, textStatus ) {
              alert( "Request failed: " + textStatus );
          });
      });
  </code></pre>
  
  <p>So where does this 0 come from? <strong>admin-ajax.php</strong> 
  it says on line 97:</p>
  
  <pre><code>// Default status
  die( '0' );
  </code></pre>
  
  <p>Why is this here, why am I reaching the die('0') line? Shouldnt it be just die() so it doesnt mess up my response?</p>
  
  <p>Seems the only way to fix this is either modify admin-ajax.php or simply die() at the end of my  send_email_callback() function.</p>