What is the difference between a response of -1 and 0 with a wordpress ajax plugin?
http://codex.wordpress.org/AJAX_in_Plugins
The documentation states:
Error Return Values
If the AJAX request fails when the request url is wp-admin/admin-ajax.php, it will return either -1 or 0 depending on the reason it failed.
But that’s a pretty basic answer and it doesn’t state what situations would trigger either type of error. Anyone have any idea?
You get a -1 when when you have an authentication-related issue:
I believe a return of 0, or 1, is used as a boolean false/true (respectively) return.
If you’re asking because you’re using this for your plugin, I highly advise you use JSON, and return something like {success: true} that way your code KNOWS that there was a valid response, and anything other than a valid JSON response I would consider as a failure.
Also don’t forget to use wp_ajax_ and wp_ajax_nopriv_ for your API added actions.