我有一個關於ajax的問題,我對它很陌生,所以不確定最好的程序。無論如何,我已經將ajax加入到我的CodeIgniter應用程序中,但我有兩種不同的響應,我不太清楚如何在我的ajax中處理這個問題。ajax響應刷新url而不是追加?
而不是將我的結果追加到一個div可以不只是刷新網址?
在我的控制器中我有表單驗證,當它是假我想刷新顯示我的錯誤,但如果它返回true我想顯示新的頁面,如果這是有道理的?
視圖
$.post("<?php echo base_url(); ?>part-one",
$("form").serialize(),
function(result){
// if errors show this
$("#error").html(result);
// if there are no errors how do I check the response to refresh the page to a new url?
}, "html"
);
控制器
if($this->form_validation->run() == FALSE){
$data['content'] = "part_one";
$this->load->view('template', $data);
} else {
$data['content'] = "part_two";
$this->load->view('template', $data);
}