# Render server response to ember main view

**URL:** https://meta.discourse.org/t/render-server-response-to-ember-main-view/47861
**Category:** Development
**Created:** [2016年七月27日 10:18 UTC](https://meta.discourse.org/t/render-server-response-to-ember-main-view/47861 "2016-07-27T10:18:25Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![EndruK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/endruk/32/50211_2.png) [@EndruK](https://meta.discourse.org/u/EndruK)
#### Post date: [2016年七月27日 10:18 UTC](https://meta.discourse.org/t/render-server-response-to-ember-main-view/47861/1 "2016-07-27T10:18:25Z")

</div>

Hi,  
I retrieve some content from my server and want to render it to the Ember Main View.

Currently I add a div called disraptorView and append via jQuery the Content retrieved from the server controller.  
The Problem is: once there is some content in this div it is always displayed when someone is navigating on the page.

I want to render my response to the Ember Main View but I have no idea how to properly do that.

This is my Ember Controller:

```plaintext
export default Ember.Controller.extend({
  init: function() {
    this.send('loadContent');
  },
  actions: {
    loadContent() {
      var pathArray = window.location.pathname.split('/');
      var subpath = pathArray[pathArray.length-1];
      var type;
      type = (subpath == "") ? "main" : "sub";
      Discourse.ajax({
        url: `/disraptor`,
        type: 'GET',
        dataType: 'text',
        data: {"url":subpath,"type":type}
      })
      .then(function(result) {
        $(".disraptorView").empty();
        $(".disraptorView").append($(result));
      })
      .catch(function(error) {
        console.log(error);
      });
    }

  }
});

```

Here is what it produces:

 ![](https://global.discourse-cdn.com/meta/original/3X/6/3/63119369be52d36c5797f40f080883f506bb76d4.png)

and when I move to another page on the client:

 ![](https://global.discourse-cdn.com/meta/original/3X/b/d/bd447806c1da920389572c64ae7125b91a574319.png)

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [2016年七月27日 15:06 UTC](https://meta.discourse.org/t/render-server-response-to-ember-main-view/47861/2 "2016-07-27T15:06:47Z")

</div>

> [@EndruK](#):
>
> Ember Main View

I’m not clear what you mean by this - where do you want your content to appear and when do you want it to go away? If you could show an example we can probably help you better.

---

<div class="post-metadata">

### Author: ![EndruK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/endruk/32/50211_2.png) [@EndruK](https://meta.discourse.org/u/EndruK)
#### Post date: [2016年八月3日 08:28 UTC](https://meta.discourse.org/t/render-server-response-to-ember-main-view/47861/3 "2016-08-03T08:28:57Z")

</div>

I want that my response is rendered in the place where the content for a route is displayed.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [2016年八月3日 16:14 UTC](https://meta.discourse.org/t/render-server-response-to-ember-main-view/47861/4 "2016-08-03T16:14:28Z")

</div>

I suggest you look at the [discourse-adplugin](https://github.com/discourse/discourse-adplugin) for an example of how to create a component that is displayed on every “page” of discourse.

---

<div class="post-metadata">

### Author: ![EndruK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/endruk/32/50211_2.png) [@EndruK](https://meta.discourse.org/u/EndruK)
#### Post date: [2016年八月4日 10:01 UTC](https://meta.discourse.org/t/render-server-response-to-ember-main-view/47861/5 "2016-08-04T10:01:39Z")

</div>

Ah thanks, that helped a lot.  
I forgot that there are outlets to do that stuff …

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [2016年八月4日 15:20 UTC](https://meta.discourse.org/t/render-server-response-to-ember-main-view/47861/6 "2016-08-04T15:20:27Z")

</div>


