0
我想要从form和ajax请求链接到控制器动作。我不能这样做。而我得到这个错误:Laravel链接到控制器动作
ErrorException
Route [admin.profile.update] not defined. (View: /var/www/alachiq/app/views/back_end/layouts/profile.blade.php)
我的形式profile.blade.php:
{{ Form::model($profile, array('action' => array('[email protected]', $profile->id), 'method' => 'PUT', 'id' => 'frm')) }}
和Ajax请求转换成:
$.post("{{ route('admin.profile.update', $profile->id) }}",
我的路线:
Route::controller('admin/profile', 'ProfileController', array('index'=>'profile.index','update'=>'profile.update'));
我的控制器:
public function getIndex()
{
$profiles = Auth::user();
return View::make('back_end.layouts.profile')->with('profile', $profiles);
}
public function postUpdate($id)
{
...
}
。我不khnow it.thanks。那么如何修复'$ .post(“<?php echo route('ProfileController @ postUpdate',$ profile-> id);?>”,' –
提交ajax请求就像其他任何请求一样,你应该可以解析$ profile-> id作为一个隐藏的输入字段 $ .post(“admin/profile”,function(data){ // do something }); –
thanks。i'change'$ .post'并把'$ profile-> id'作为隐藏的输入标签。witch name必须解析那个吗?''input type =“hidden”name ='id'value =“{{$ profile-> id}}”/>是'id:$('[name = id]')。val(),'currect? –