This document suggests using die()
, but current WP seems to use wp_die()
, which will eventually call _ajax_wp_die_handler()
for simple responses.
More complex responses are being handled with wp_send_json()
and its friends, wp_send_json_error()
and wp_send_json_success()
.
Most of my code uses the old die()
pattern here, but I'll update the main page when I have some text and examples in mind.
Misterbisson 15:51, 20 August 2014 (UTC)
As I just wrote in AJAX: I'm going to be correcting usage: Ajax, not AJAX. Viz.:
--bentrem 19:46, 9 February 2008 (UTC)
Hi,
I added a link to my recent blog post about using Ajax in WordPress plugins and themes ( 5 tips for properly using Ajax in WordPress hemes and Plugins ). I'd like to stress that this is not any form of self-promotion.
If the editors don't find my article useful enough to include, feel free to remove it. No hard feelings :) But please do read the article before making any decisions.
Hi,
I just created a AJAX in WordPress QuickStart Guide. I found that there wasn't anything handy to get started quickly and AJAX can sometimes be finicky. I'm adding the link to the page; but, as above, I'd like to stress that this is not any form of self-promotion. Only, that I wish I had such a post when I was figuring it out myself. If the editors don't find my article useful enough to include, feel free to remove it.
Am I crazy or does the example not work as written?
Vynce 08:39, 22 April 2011 (UTC)
DanDare2050 (talk) 07:21, 2 January 2015 (UTC)
"NOTE: Since Version 2.8, The JavaScript global variable ajaxurl can be used in case you want to separate your JavaScript code from php files into JavaScript only files. This is true on the administration side only."
This seems a bit cryptic. As I understand it the ajaxurl is the url to the instance of wordpress and the ajax call handling doohicky (technical term). How does that have anything to do with separating javascript code from php code? What am I missing?
Thinks.
Ok, you mean
"NOTE: Since Version 2.8, The JavaScript global variable ajaxurl has been loaded with the correct url for ajax calls to Wordpress. This means you may write pure javascript files that use this variable without having to pass it from some PHP generated code. This can be used in case you want to separate your JavaScript code from php files into JavaScript only files. This is true on the administration side only."
Less ambiguous?