I'm trying to understand why using admin-ajax.php is advantageous over doing something like this:
add_action ('wp_loaded', 'my_ajax');
function my_ajax() {
// Do Ajax, Check $_POST
die();
}
With the JQuery ajax just pointing to the blog's index.
admin-ajax.php seems rather convoluted to do something simple, with having to register scripts and add hooks and set up a js variable url to point to the admin-ajax.php and then with wp_ajax_nopriv_ vs wp_ajax_. Not to mention it's kind of weird that back end is being mixed with the front end. I'm pretty sure there's an analogy there.
So why use it? Does admin-ajax.php have less overhead? Is it purely a standards thing? Is there something magical about it? What do you miss out by not using it?
admin-ajax.php
file? There's nothing stopping you from doing it your way, but usingadmin-ajax.php
offers some functionality that developers may want to take advantage of without having to recreate for each AJAX function.