$.getJSON request returns a 404 error
I'm trying to learn jQuery from a book called Learning jQuery by Jonathan Chaffer & Karl Swedberg, and have ran into a problem that I cannot figure out.
There is a b.json file provided by the book resources that should load with this statement:
- $.getJSON('b.json', function (data) ....
When I run the code I am getting a 404 not found error in the Chrome debugging tool stating the b.jason file cannot be found. I have the b.json file in the FormExanples folder which is odd to me that it's not finding the file.
http://localhost:52000/FormExamples/b.json
The script file looks like this:
- $(document).ready(function() {
- $('#letter-b .button').click(function() {
- $.getJSON('b.json', function (data) {
- $('#dictionary').empty();
- $.each(data, function(entryIndex, entry) {
- var html = '<div class="entry">';
- html += '<h3 class="term">' + entry['term'] + '</h3>';
- html += '<div class="part">' + entry['part'] + '</div>';
- html += '<div class="definition">';
- html += entry['definition'];
- if (entry['quote']) {
- html += '<div class="quote">';
- $.each(entry['quote'], function(lineIndex, line) {
- html += '<div class="quote-line">' + line + '</div>';
- });
- if (entry['author']) {
- html += '<div class="quote-author">' + entry['author'] + '</div>';
- }
- html += '</div>';
- }
- html += '</div>';
- html += '</div>';
- $('#dictionary').append(html);
- });
- });
- });
- });
and the JSON file:
- [
- {
- "term": "BACCHUS",
- "part": "n.",
- "definition": "A convenient deity invented by the ancients as an excuse for getting drunk.",
- "quote": [
- "Is public worship, then, a sin,",
- "That for devotions paid to Bacchus",
- "The lictors dare to run us in,",
- "And resolutely thump and whack us?"
- ],
- "author": "Jorace"
- },
- {
- "term": "BACKBITE",
- "part": "v.t.",
- "definition": "To speak of a man as you find him when he can't find you."
- },
- {
- "term": "BEARD",
- "part": "n.",
- "definition": "The hair that is commonly cut off by those who justly execrate the absurd Chinese custom of shaving the head."
- },
- {
- "term": "BEGGAR",
- "part": "n.",
- "definition": "One who has relied on the assistance of his friends."
- },
- {
- "term": "BELLADONNA",
- "part": "n.",
- "definition": "In Italian a beautiful lady; in English a deadly poison. A striking example of the essential identity of the two tongues."
- },
- {
- "term": "BIGAMY",
- "part": "n.",
- "definition": "A mistake in taste for which the wisdom of the future will adjudge a punishment called trigamy."
- },
- {
- "term": "BORE",
- "part": "n.",
- "definition": "A person who talks when you wish him to listen."
- }
- ]
Could someone help me understand why jquery is returning this 404 error with the exact path to where the JSON file is located?