Do you want to delete posts in WordPress admin without reloading the page? If so, then this article is for you. I will show you how to use AJAX to delete posts in WordPress admin page.
Here is the result you will get:

Catch event when user clicks delete post with jQuery
The code below will catch the event when the user deletes the post. Put it in the functions.php file of the theme or child theme.
add_action( 'admin_footer', 'hk_extend_admin_js' );
function hk_extend_admin_js() {
ob_start(); ?>
<?php $output = ob_get_contents();
ob_clean();
ob_end_flush();
echo $output;
}
[/code]<p>Here, I use the action hook <code><a href="https://developer.wordpress.org/reference/hooks/admin_footer/" target="_blank" rel="noopener">admin_footer</a></code> to add the above jQuery code to the footer of the admin page.</p>
<p>At line 7, you can replace <code>.post-type-post</code> with the appropriate custom post type name. Namely: <code>.post-type-{POST TYPE NAME}</code> .</p>
<h2 id="xu-ly-ajax-1">AJAX handling</h2>
<p>The following code is also included in the <code>functions.php</code> file :</p>

