可以传递值,如下面的代码:
<script type="text/javascript">
$('#modal-save').on('click',function(){
$.ajax({
type : 'post',
url : urlEdit,
data : {body : $('#post-body').val(), postId: postId , _token:token }
}).done(function(msg){
//console.log(msg.new_body);
$(PostBodyElement).text(msg['new_body']);
$('#edit-modal').modal('hide');
});
});
</script>
这应该是在你的控制器 公共职能postEditPost(请求$要求) {$ 这 - >的validate($请求,[ “ body'=>'required' ]); $ post = Post :: find($ request ['postId']); if(Auth :: user()!= $ post-> user) { return redirect() - > back(); } $ post-> body = $ request ['body']; $ post-> update();返回response() - > json(['new_body'=> $ post-> body],200); }
而在乌尔路线: 路线::交( '/编辑',[ '使用'=> 'PostController中@ postEditPost', '作为'=> '编辑' ]);
你的HTML链接,请给我的html代码 – Komal