Ember.js-in-Action-Source
Ember.js-in-Action-Source copied to clipboard
blogPosts JSON file not found
I'm not sure why, but it looks like jQuery is trying to look for the blogPosts JSON, and it's not finding it. I've mirrored my app structure to yours, but something's amiss. Here's a screenshot of my Chrome inspector.
You can check out my repo here. What am I doing wrong?
Just cloned this repo and tried. None of the examples in the chapter 3 folder work. index.html
, index1.html
, index2.html
, and index3.html
all have different errors. But here's the console output of index.html
.
DEBUG: ------------------------------- ember-1.0.0.js:394
DEBUG: Ember.VERSION : 1.0.0 ember-1.0.0.js:394
DEBUG: Handlebars.VERSION : 1.0.0 ember-1.0.0.js:394
DEBUG: jQuery.VERSION : 1.10.2 ember-1.0.0.js:394
DEBUG: ------------------------------- ember-1.0.0.js:394
event.returnValue is deprecated. Please use the standard event.preventDefault() instead. jquery-1.10.2.min.js:5
OPTIONS file://localhost/blogPosts jquery-1.10.2.min.js:6
DEPRECATION: Action handlers contained in an `events` object are deprecated in favor of putting them in an `actions` object (error on <Ember.Route:ember279>)
at Object.triggerEvent (file://localhost/Users/macbookpro/Sites/Ember.js-in-Action-Source/chapter3/blog/js/scripts/ember-1.0.0.js:30519:13)
at trigger (file://localhost/Users/macbookpro/Sites/Ember.js-in-Action-Source/chapter3/blog/js/scripts/ember-1.0.0.js:29641:16)
at handleError (file://localhost/Users/macbookpro/Sites/Ember.js-in-Action-Source/chapter3/blog/js/scripts/ember-1.0.0.js:29903:9)
at invokeCallback (file://localhost/Users/macbookpro/Sites/Ember.js-in-Action-Source/chapter3/blog/js/scripts/ember-1.0.0.js:8055:19)
at null.<anonymous> (file://localhost/Users/macbookpro/Sites/Ember.js-in-Action-Source/chapter3/blog/js/scripts/ember-1.0.0.js:8109:11)
at EventTarget.trigger (file://localhost/Users/macbookpro/Sites/Ember.js-in-Action-Source/chapter3/blog/js/scripts/ember-1.0.0.js:7878:22)
at file://localhost/Users/macbookpro/Sites/Ember.js-in-Action-Source/chapter3/blog/js/scripts/ember-1.0.0.js:8180:17
at Object.DeferredActionQueues.flush (file://localhost/Users/macbookpro/Sites/Ember.js-in-Action-Source/chapter3/blog/js/scripts/ember-1.0.0.js:5459:24)
at Object.Backburner.end (file://localhost/Users/macbookpro/Sites/Ember.js-in-Action-Source/chapter3/blog/js/scripts/ember-1.0.0.js:5545:27) ember-1.0.0.js:394
Error while loading route:
Object {readyState: 4, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function…}
ember-1.0.0.js:394
Uncaught #<Object> ember-1.0.0.js:30566
It looks like it's looking for blogPosts
in a higher directory. Any help you can give on this? I assumed I did something wrong, but I do find it weird that this repo doesn't work.
Are you hosting the application so that it is accessible via http://localhost:8080/index.html? Ember Data is expecting to find you blogPost file directly under the "/" in your web application.
I guess that makes sense, but the code in chapters 1 and 2 can be run off of the file:///
directive without a local server. You don't mention running a local server in the book, and there isn't any sign of one in this repo.
I just set up a server using Sinatra, and though it can find the blogPosts
JSON file, I'm still getting a number of errors. Here is a screenshot of my console.
Worth noting that those are the same errors I get when using the file:///
directive, with the exclusion of the 404 on the blogPosts
.
I agree with @thenickcox. The book doesn't mention that this example has to be run with a webserver. (I assumed that file:///
would have been fine.) Can the book be updated to reflect this?