# Slim ajax- what to put in tht return

**URL:** <https://discourse.slimframework.com/t/slim-ajax-what-to-put-in-tht-return/1678>\
**Category:** Questions\
**Created:** [July 15, 2017, 12:12pm UTC](https://discourse.slimframework.com/t/slim-ajax-what-to-put-in-tht-return/1678 "2017-07-15T12:12:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![haizone](https://avatars.discourse-cdn.com/v4/letter/h/ad7895/32.png) [@haizone](https://discourse.slimframework.com/u/haizone)\
**Post date:** [July 15, 2017, 12:12pm UTC](https://discourse.slimframework.com/t/slim-ajax-what-to-put-in-tht-return/1678/1 "2017-07-15T12:12:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![marcelloh](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/marcelloh/32/404_2.png) [@marcelloh](https://discourse.slimframework.com/u/marcelloh)\
**Post date:** [July 19, 2017, 5:43am UTC](https://discourse.slimframework.com/t/slim-ajax-what-to-put-in-tht-return/1678/2 "2017-07-19T05:43:44Z")

</div>

You can use knockout ([http://knockoutjs.com/](http://knockoutjs.com/)) to communicate from Slim to items on your webpage.  
You can do what you want (replace a text within tags), or make a list that is filled with a json response from Slim.

Don’t try to invent the wheel 😉  
Knockout has good help to start with and is very easy to implement.
