【发布时间】:2015-09-15 00:39:55
【问题描述】:
下面是我的数据库:
post:
id user_name content created_at
下面是我的后期控制器:
public function new(Request $request){
$data = $request->all();
$post = new Post;
$post->user_name = $data['name'];
$post->message = $data['content'];
$post->save();
$id = $post->id;
$show = Post::find($id)->first();
// $html = view('wall.post')->with('post', $show);
return response()->json(['success' => $post->id,'message'=> 'Post Sent', 'html' => $html]);
}
还有我的 /views/wall/post.blade.php :
<div class="ui post">
<div class="name">User : {{ $post->user_name }}</div>
<div class="content">{{ $post->content }}</div>
</div>
下面是我的问题:
我如何使用 user_name 从 post.blade.php 获取内容和 当我发布 name=kenny 和 content=testing 时,content 返回到 new() 中的 $html:
<div class="ui post">
<div class="name">User : Kenny</div>
<div class="content">Testing</div>
</div>
我只是使用 jquery 将上述代码添加到我的页面中?
谢谢
{对不起,如果我的英语语法不好}
【问题讨论】:
标签: php jquery mysql json laravel-5.1