簡體   English   中英

如何將用戶重定向到CMS中的另一個頁面

[英]How to redirect a user to another page within the CMS

我正在開發內容管理系統(CMS)。 我是用php完成的,但是現在我想添加jquery,因為我不希望在提交表單時重新加載頁面。 我可以使用jquery提交表單。 我現在想要的是在提交表單后將用戶帶到CMS中的其他頁面(desired_pa​​ge.php),替換包含表單的頁面。 我可以使用window.open('index.php?desired_pa​​ge','_ self')用php做到這一點,但是我不知道如何用jquery做到這一點。 window.location.replace(“ desired_pa​​ge.php”)實際上將我重定向到了desired_pa​​ge.php,但在CMS之外。 提交表單后,如何將表單替換為required_pa​​ge.php? 我的代碼如下所示:

的HTML

<form action="set_date_form.php" id="setdate" method="post" >
<input type="text" name="date" id="datetimepicker" placeholder="Choose Date" class="form-control" maxlength="2" required/>
<button id="subdate"class="btn btn-default" ><b>Set Date</b></button>
</form>

Java腳本

$('body').on('click', '#subdate', function(){
    $.post($("#setdate").attr("action"), $("#setdate").serialize(), function(info){ $("#resultm").html(info); } );
    clearInput();
    pageRedirect();
});

$('body').on('submit', '#setdate', function(event){
    event.preventDefault();
    return false;
});
function pageRedirect() {
    window.location.replace("sent_messages.php");
}
setTimeout("pageRedirect()", 10000);
function clearInput() {
  $("#setdate")[0].reset(); 
}

使用window.location.replace時,需要指定頁面的完整URL才能導航到該頁面。

例如:window.location.replace(“ http://www.example.com/sent_messages.php ”);

如果您要用desirable_page.php替換表單,請使用Jquery Load替換表單中的內容。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM