Timeline for Why is die() used at the end of function that handles an Ajax request?
Current License: CC BY-SA 4.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 11, 2018 at 11:07 | comment | added | Tim | Worth noting that wp_die can also be hooked by other plugins (via wp_die_ajax_handler). Nobody wants to use die or exit, but if you're publishing a plugin there's a risk of conflict if you don't. I even handle my own output buffering due to themes and plugins that produce junk output mid-execution. | |
S Sep 11, 2018 at 7:54 | history | suggested | Peter Mortensen | CC BY-SA 4.0 |
Copy edited (e.g. ref. <http://en.wikipedia.org/wiki/Ajax_%28programming%29>, <http://en.wikipedia.org/wiki/JSON>, and <http://en.wikipedia.org/wiki/Uniform_resource_locator>).
|
Sep 11, 2018 at 5:51 | review | Suggested edits | |||
S Sep 11, 2018 at 7:54 | |||||
Sep 11, 2018 at 3:27 | comment | added | Mark Kaplun | tnx @gmazzap, been a long while since I looked at the details of that code | |
Sep 10, 2018 at 18:19 | comment | added | gmazzap |
admin-ajax.php always adds output if request is not stopped. So, unless the caller of the AJAX ignores the output, the die is basically required, even if the wrapper wp_die should be preferred because a function containing die is pretty-much impossible to test.
|
|
Sep 10, 2018 at 8:16 | vote | accept | CommunityBot | ||
Sep 10, 2018 at 8:10 | comment | added | Mark Kaplun | because wordpress continues to run and will try to handle the url. If the execution will trigger plugins that do not properly check the context in which their code is being run you might get output (most likely some php error if they expect to be called only in other context) | |
Sep 10, 2018 at 8:07 | comment | added | user145078 | Thank you for answer. A little confused with extra output..if there is no data get from the request,how extra output get generated? Also will it add up the server resources? | |
Sep 10, 2018 at 8:02 | history | answered | Mark Kaplun | CC BY-SA 4.0 |