Every time I do a particular Ajax request at the end of the result I get a 0. Why am I getting this and is there a way to get rid of it?

The result is good it's just followed by a zero for some reason.

  • You will need to add some of your code to get more help – Douglas.Sesar Apr 9 '14 at 21:05
  • 2
    Put a die() at the end of the script – Andrew Bartel Apr 9 '14 at 21:15
  • I just did. I got tired to looking around. – jnbdz Apr 9 '14 at 21:33

WordPress does that by default at the end of admin-ajax.php. It kind of assumes you'll use one of wp_send_json(), wp_send_json_success(), or wp_send_json_error() to communicate your process' state (or at least terminate the script yourself). All of those use wp_die() to terminate the script after sending the response. It's sort of a catch-all response.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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