Because you are doing it wrong. But then I guess you already know that. An exit status or return code is a numerical representation of whether a process worked and how it worked. Although it does vary, you won’t go far wrong with this:
- -1 (or less) – the process failed. An error happened.
- 0 – there were no errors. But nothing happened, you failed to trigger any change.
- 1 (or more) – success. The process did something.
How does WordPress handle bad AJAX?
WordPress returns 0 if you do something silly (like forgetting to add the ajax hook). If you write something that actually breaks, then it will just fail silently (you don’t see the error, unless you use something like FireBug). So if you are seeing -1 then the ajax hook itself is explicitly telling you that you are doing something wrong. And whatever that is, it depends on what you are trying to do. Sadly debugging techniques like this fall outside of the scope of my blog. I suggest visiting the WordPress support forums.