hi i do a ajax script this is my controller:
public function newajax($request, $response){
$articles = Article::find(1);
$comment = new Comment;
$comment->body = $request->getParam('body');
$comment->user()->associate($this->auth->user());
$articles->comments()->save($comment);
return $this->view->render($response,'home.html',compact('comment'));
}
and this is my HTML:
<h1><div id="text"></div></h1> <script> $("button").click(function(){ $("input").keyup(function(){ var body = $("input").val(); $.post("{{ path_for('newajax') }}",{ body : body },function(data){ $("test").html }); }); }); </script>
what i need to put in the return controller to stay in the same page and show the new comment in <h1> tag
thanku