Php 是否可以通过ajax请求更改laravel中的布局内容?
这是控制器文件,用于设置视图布局Php 是否可以通过ajax请求更改laravel中的布局内容?,php,ajax,laravel-4,blade,Php,Ajax,Laravel 4,Blade,这是控制器文件,用于设置视图布局 class DashboardController extends BaseController{ public function __construct(){ $this->layout='expert-dashboard::layouts.default'; } public function index(){ $action=Input::get('action'); if
class DashboardController extends BaseController{
public function __construct(){
$this->layout='expert-dashboard::layouts.default';
}
public function index(){
$action=Input::get('action');
if($action=="dashboard"){
$this->layout->content=View::make(Config::get('expert-dashboard::dashboard'));
return ;
}else{
$this->layout->content=View::make(Config::get('expert-dashboard::activity'));
return;
}
}
}
js代码,调用动作动态替换为不同的内容。结果显示,布局内容已更改,但未呈现。原因是什么,否则如何呈现更改
$scope.changeContent=function(){
$http({
method: 'GET',
url: './dashboard',
params:{
"action":"dashboard"
},
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).
success(function(response) {
}).
error(function(response) {
});
};
您需要将联系人从Laravel返回到jquery函数,然后让jquery更新DOM元素当然我知道要通过jquery/javascript更新DOM元素,但我在这里讨论的是,是否可以通过Laravel中的控制器更新视图。