What's the distinction between an answer of -1 and having a wordpress ajax wordpress plugin?
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 is quite a fundamental answer also it does not condition what situations would trigger either kind of error. Anybody have idea?
You receive a -1 when if you have an authentication-related problem:
- The present user isn't drenched in, or doesn't have permissions to complete some kind of asked for action.
- There's no asked for action published, or even the published action isn't found.
In my opinion coming back of , or 1, can be used like a boolean false/true (correspondingly) return.
If you are asking because you are by using this for the wordpress plugin, I highly counsel you use JSON, and return something similar to this way your code Recognizes that there is a legitimate response, and anything apart from a legitimate JSON response I'd consider like a failure.
Also be sure to use wordpress_ajax_ and wordpress_ajax_nopriv_ for the API added actions.