Jquery isAjax()是CakePHP 2.0上不推荐使用的方法。什么方法代替那方法?
这是我的密码Jquery isAjax()是CakePHP 2.0上不推荐使用的方法。什么方法代替那方法?,jquery,cakephp-2.0,Jquery,Cakephp 2.0,这是我的密码 function add() { if(!empty($this->data)) { if($this->Post->save($this->data)) { if($this->RequestHandler->isAjax()){ //isAjax method is deprecated. //Handle Ajax $th
function add() {
if(!empty($this->data)) {
if($this->Post->save($this->data)) {
if($this->RequestHandler->isAjax()){ //isAjax method is deprecated.
//Handle Ajax
$this->render('notif','ajax');
} else {
$this->Session->setFlash('Add successfully');
$this->redirect(array('action'=>'index'));
}
}
else {
$this->Session->setFlash('Add failded please try again');
}
}
}
在这里,我读到该方法已被弃用
如何解决这个问题?它说CakeRequest现在要对此负责。您可以在此处找到适当的段落:
它说CakeRequest现在对此负责。您可以在此处找到适当的段落:
function add() {
if(!empty($this->request->data)) {
if($this->Post->save($this->request->data)) {
if($this->request->is('ajax')){
//Handle Ajax
$this->render('notif','ajax');
} else {
$this->Session->setFlash('Add successfully');
$this->redirect(array('action'=>'index'));
}
}
else {
$this->Session->setFlash('Add failded please try again');
}
}
}