success: function(response){ if (response.success) { // Hide the row nicely and remove it from the DOM once the animation is finished. currentRow.fadeOut(500, function(){ currentRow.remove(); }); } else { // throw an error modally to let the user know there was an error console.log(data); } } }) }); </script> </div> <?php } } global $newsletter; $newsletter = new Newsletter(); function addToNewsletter($email, $name = '') { global $newsletter; return $newsletter->insertSubscriber($email, $name); } if (isset($_POST['action']) && isset($_POST['id']) && $_POST['action'] === 'removeSubscriber' && is_user_logged_in()) { $postToDelete = $_POST['id']; $newsletter->removeSubscriber($postToDelete); wp_send_json_success(['deletedPost' => $postToDelete]); }