How to Handle AJAX Requests in WordPress with wp_ajax
Handle AJAX requests in WordPress with wp_ajax WordPress has its own AJAX entry point: every request goes to wp-admin/admin-ajax.php with an action parameter, and WordPress calls the PHP function registered for that action. All of WordPress is loaded, so in the handler you can use any function, check the user and work with the database.
Details