Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8840483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:28:30+00:00 2026-06-14T10:28:30+00:00

I’m new to Ember and I’m having a problem loading JSON from a URL.

  • 0

I’m new to Ember and I’m having a problem loading JSON from a URL. Here’s what I have:

var App = Ember.Application.create();

App.ApplicationController = Ember.Controller.extend();
App.ApplicationView = Ember.View.extend({ templateName: 'application' });

App.OrdersListController = Ember.Controller.extend();
App.OrdersListView = Ember.View.extend({ templateName: 'orders' });

App.Order = Ember.Object.extend();
App.Order.reopenClass({
  find: function(){
     //not implemented yet 
  },
  findAll: function(){
      var content = [];
      $.ajax({
      url: 'http://api.domain/orders',
      dataType: 'jsonp',
      success: function(response){
        response.data.forEach(function(order){
          this.content.addObject(App.Order.create(order))
        }, this)
      }
    });
    return this.content;
  }
});

App.Router = Ember.Router.extend({
  enableLogging: true,
   // The initial state for the router, contains every other.
  root: Ember.Route.extend({
    goOrders: Ember.Route.transitionTo('orders'),
    goLocations: Ember.Route.transitionTo('locations'),
    goReports: Ember.Route.transitionTo('reports'),
    goUsers: Ember.Route.transitionTo('users'),
    goHelp: Ember.Route.transitionTo('help'),
    //Authenticated routes
    index: Ember.Route.extend({
        route: '/',
        redirectsTo: 'orders'
      }),
    orders: Ember.Route.extend({
      route:'/orders',
      initialState: 'index',
      //Orders view.
      index: Ember.Route.extend({
        route: '/',
        connectOutlets: function(router) {
          router.get('applicationController').connectOutlet({
            name:'ordersList', 
            context: App.Order.findAll()
          });
        }
      })
    })
  })
});

App.initialize();

And in my template (simplified):

<script type="text/x-handlebars" data-template-name="application">
    {{outlet}}
</script>

<script type="text/x-handlebars" data-template-name="orders">
    {{#each order in controller.content}}
<p>id: {{order.ord_id}}</p>
    {{/each}}
</script>

With this I don’t get and error but nothing shows up. If I paste he JSON in the context of the connectOutlet it works though. Is there a problem with my findAll() function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:28:31+00:00Added an answer on June 14, 2026 at 10:28 am

    I would try this one:

    findAll: function(){
          var content = [];
          $.ajax({
          url: 'http://api.domain/orders',
          dataType: 'jsonp',
          success: function(response){
            response.data.forEach(function(order){
              content.addObject(App.Order.create(order))
            }, this)
          }
        });
        return content;
      }
    

    As you see, i just removed the this pointer two times. I think the this pointer in this case points to an the Order class, which does not have a content property. But you want to reference the var you defined. Therefore it should be without this.

    Note: I do also have trouble from time to time with the this pointer, when fetching data. But this structure has always worked for me so far. So it should work, but my explanation might not be perfect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have been unable to fix a problem with Java Unicode and encoding. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.