Javascript 从表中删除数据后如何刷新选项卡

Javascript 从表中删除数据后如何刷新选项卡,javascript,php,jquery,ajax,html,Javascript,Php,Jquery,Ajax,Html,从数据库中删除数据后,该选项卡将返回到表选项卡,但不会刷新。我尝试重新加载,但是标签跳转到主页,并且从未停止刷新。table.tablerefresh没有响应。 我也试过了 window.location = "Home.php"; 这将刷新并跳转到主页,但如果我这样做了 window.location = "Home.php#SectionB"; 这不会跳转,也不会刷新 有人能帮我吗?需要刷新选项卡,但请保持在此选项卡上 <!DOCTYPE html> <html lan

从数据库中删除数据后,该选项卡将返回到表选项卡,但不会刷新。我尝试重新加载,但是标签跳转到主页,并且从未停止刷新。table.tablerefresh没有响应。 我也试过了

window.location = "Home.php";
这将刷新并跳转到主页,但如果我这样做了

window.location = "Home.php#SectionB";
这不会跳转,也不会刷新

有人能帮我吗?需要刷新选项卡,但请保持在此选项卡上

<!DOCTYPE html>
<html lang="en">
<head>
    <link href="css/bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <script>
    // Confirm if user want to delete the selected event from database
    function confirmDelete() {
        var r = confirm("Are you sure you want to delete this event?");
        return r;
    }
    </script>
</head>
<body>
    <h2 class="form-nasa-heading" align="center">Events Detail</h2>
    <form name="deleteEvent" method="post">
    <table  style="width:100%" class="detail table table-bordered" id="showevent">
        <tr>
            <th>Description</th>
            <th>Delete</th>
        </tr>
        <?php 
        require '../others/ConnectDB.php';
        $sql = 'SELECT * from Events';
        foreach($db->query($sql) as $events)
        {
            echo '<tr><td>';
            echo $desc = $events['Desc'];
            echo '</td>';
            echo '<td>';
            echo '<button name="deleteEvent" class="btn btn-primary glyphicon glyphicon-remove" type="submit" onclick="return confirmDelete()"></button>';
            echo '<input name=eventId value="',$events['ID'],'"  type="hidden">';
            $eventId = $events['ID'];
            echo '</td>';
            echo '</tr>';
        }
        ?>
    </table></form>
</body>
<?php
function DeleteEvent(){
    require '../others/ConnectDB.php';
    $eventId = $_POST['eventId'];
    if(isset($eventId)){
// Delete selected event from database
        $sqlDeleteEvent = "DELETE FROM Events WHERE ID= \"$eventId\"";
        $resultDeleteEvent = $db->query($sqlDeleteEvent);

// Show Success alert
        if($resultDeleteEvent) {    
            echo '<script language="javascript">
            alert("You Have Delete Event Successfully!!");
            $(\'a[href="#SectionB"]\').tab(\'show\');
            $("#showevent").table("refresh");
            </script>';
        } 
    }
}
if(isset($_POST['deleteEvent'])){
    DeleteEvent();
}
?>
</html>
我的标签是:

<div class="nav-tabs" role="navigation">
<ul class="nav nav-tabs" data-tabs="tabs">
<li class="active"><a data-toggle="tab" href="#SectionA">Home</a></li>
<li><a data-toggle="tab" href="#SectionB">Events</a></li>
</ul>
</div>     
<div id="my-tab-content" class="tab-content">
<div class="tab-pane active" id="SectionA">
<?php
    include_once('Welcome.html');
?>
</div>
<div class="tab-pane" id="SectionB">
<?php
    include_once('EventsPage.php');
    ?>
</div>

删除后,您可以使用同一页面的标题,使其重定向到同一页面

if(isset($_POST['deleteEvent'])){
    DeleteEvent();
    header('Location: http://www.example.com/');
}

这将跳转到主页,而不是停留在选项卡上。正如我所说,我不想让它跳起来,它不是那样工作的。这就是为什么我使用$\'a[href=SectionB]\'。选项卡“show\”;