Javascript 单击submit按钮时如何使用jQuery在cakephp中重新加载页面
在我的程序中,我想在单击“注释”按钮时重新加载页面。实际情况是,它确实会更新数据库中的数据,但我必须手动重新加载,而不是在单击“注释”按钮后立即重新加载页面Javascript 单击submit按钮时如何使用jQuery在cakephp中重新加载页面,javascript,jquery,cakephp-2.0,Javascript,Jquery,Cakephp 2.0,在我的程序中,我想在单击“注释”按钮时重新加载页面。实际情况是,它确实会更新数据库中的数据,但我必须手动重新加载,而不是在单击“注释”按钮后立即重新加载页面 echo $this->Js->submit('Comment', array( 'before' => $this->Js->get('#busy-indicator')->effect(
echo $this->Js->submit('Comment',
array(
'before' => $this->Js->get('#busy-indicator')->effect('fadeIn', array('buffer' => false)),
'complete' => $this->Js->get('#busy-indicator')->effect('fadeOut', array('buffer' => false)),
//'before'=>'alert("Comment posted");',
//'success'=>'jQuery("#PostComment").val("");',
'url' => array(
'controller' => 'posts',
'action' => 'comment/'.$post['Post']['id']
),
'update' => '#UserComment',
//'class'=>'submit',
'class' => 'comment',
'id'=>'SubmitComment',
));
单击“注释”按钮后,您可以重定向到同一页面 返回$this->redirect($this->here);或 返回$this->redirect($this->request->here);//蛋糕2.x 假设我们在控制器中有一个处理注释的函数
公共函数注释(){
//在此处处理内容。。。
//用一条漂亮的消息立即重定向用户
$this->flash('您的评论已保存,谢谢','是的,谢谢您这么做,但我想要的是,当它完成后,我想重新加载的是他们的任何选项?当前,单击评论按钮时会发生什么。将您的按钮更改为此。echo$this->Html->link('评论','/redirect/url',array('class'=>'按钮'));这样可以重定向到注释函数。
public function comment() {
// process content here...
// redirects the user immediately with a nice message
$this->flash('Your comment has been saved, thanks', '<page you wish to redirect');
OR
$this->setFlash('blablablabla');
return $this->redirect($this->here); // this->here refers to the current pageurl
OR
return $this->redirect($this->request->here); // cake 2.x (// this->request->here refers to the current pageurl)
}