Making jquery ajax call from view to controller in cakephp 2.x

…衆ロ難τιáo~ 提交于 2019-12-02 06:42:51
/*IN THE AJAX REQUEST YOU SHOULD HAVE*/
$.ajax({
.....
success: function(data){ $('#MYDIV').html(data);}, //YOU CAN APPEND OR REPLACE THE CONTENT OF A CONTAINER WITH THE RESPONSE
...
});

//in DealsController::topdeals() you should have at the begining
if ($this->request->isAjax()):
        $this->layout = null;
        $this->view = 'view_ajax'; //Other view that doesn't needs layout, only if necessary 
    endif;

/*DO WHATEVER YOU WANT HERE, SEND IT TO THE VIEW, THE VIEW GETS RENDERD AND RETURN AS A RESULT*/
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!