[英]CakePHP submit form then redirect not working
我正在嘗試創建一個提交表單的按鈕,然后將其重定向到另一個頁面。
$('#saveApp').click(function() {
event.preventDefault();
$("form[id='CustomerSaveForm']").submit(); // use the native submit method of the form element
window.location.href = "<?php echo EWConfig::$URL?>/ExpressWay/ProgramApplications/sales/residence";
return true;
});
盡管注釋掉了事件,這將重定向但不提交表單event.preventDefault()
將相反。
最終使用了服務器端解決方案。
視圖
echo $this->Form->button('Save and Redirect', array('name' => 'data[redirect]'));
控制者
if(!is_null($this->request->data('redirect'))){
$this->redirect(array('controller' => 'Program', 'action' => 'index'));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.