Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Alejandro Carvajal
9,100 PointsjQuery Broken Loop?
I finished the AJAX Basics Course last week, where it teaches the jQuery with AJAX Shorthand Methods.
I am having a little bit of a problem on making the jQuery work in my program. You see, when I run my page and I try to check my progress in the console, nothing displays.
jQuery-
$(document).ready(function(){
var url = 'ingredientsList.json';
$.getJSON(url,function(response){
each(response, function(index, ingredient){
if(ingredient.salty === false){
console.log(index + ', ' + ingredient + "is Not Salty")
}
}); //END OF EACH CALLBACK
}); // END OF getJSON() CALLBACK
});//END READY FUNCTON
JSON-
[
{
"id": "1",
"name": "mozzarella cheese",
"type": "dairy",
"continentOfOrigin": "europe",
"salty" : true
},
{
"id": "2",
"name": "olive oil",
"type": "oil",
"continentOfOrigin": "europe",
"salty" : true
},
{
"id": "3",
"name": "yellow onion",
"type": "vegetable",
"continentOfOrigin": "asia",
"salty" : true
},
{
"id": "4",
"name": "better boy tomato",
"type": "fruit",
"continentOfOrigin": "south america",
"salty" : false
},
{
"id": "5",
"name": "salt",
"type": "condiment",
"continentOfOrigin": "asia",
"salty" : true
},
{
"id": "6",
"name": "dried oregano",
"type": "condiment",
"continentOfOrigin": "europe",
"salty" : false
}
]
Thanks in advance If you got to figure out the problem.
1 Answer
Dave StSomeWhere
19,870 PointsI'd recommend that you double check your command syntax to begin your loop.
Alejandro Carvajal
9,100 PointsAlejandro Carvajal
9,100 Points😅😅😅 It must have been late, what a careless mistake. 😂 Thanks a ton