How to send Ajax request from my plugin in admin dashboard?

Here’s a base snippet I use for AJAX submits in WordPress. It does use jQuery, but there’s no reason vanilla won’t work. You could admin_enqueue_scripts() the <script>, and conditionalize it on the proper page with get_current_screen(). add_action( ‘admin_menu’, function(){ add_menu_page( ‘My Plugin’, ‘My Plugin’, ‘manage_options’, ‘my_plugin_slug’, ‘my_plugin_page’, ‘dashicons-cloud’ ); }); function my_plugin_page() { if (isset($_POST[‘my_plugin_ajax_submit’])) … Read more