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

JavaScript AJAX Basics (retiring) Programming AJAX Processing JSON Data

Vera Gominho
Vera Gominho
3,277 Points

The list on employees doesn't show on the webpage

Hi, everyone.

For some reason, the list that should appear on the webpage, with the respective labels doesn't appear =(

Can you tell me what's wrong with my code? I even tried to copy-paste the code that worked for other people her in the questions, an i still have the same problem .

Here is my code: https://w.trhou.se/61wazogqxa

Thanks!

4 Answers

You have two things going on

(1) There is no reference to widget.js in your index.html file. The following is included in the head of the video's workspace html

<script src="js/widget.js"></script>

Without it none of the javascript executes.

(2) The initialization in your for loop in widget.js has a syntax error. Instead of:

for(var = i; i<employees.length; i+=1){

it should be

for(var i = 0; i<employees.length; i+=1){
Anis Shili
Anis Shili
12,787 Points

problem in the for loop. exactly in the declaration of the i variable

Vera Gominho
Vera Gominho
3,277 Points

Thank you so much! Such a silly mistake! its working now :)

Hi Vera Gominho ,

Pretty close with your code so don't worry.

Issue

There were two updates I needed to make to get your code working.

  1. The widget.js wasn't included in your index.html via a script tag.
  2. An error in the widget.js employees for loop.

Fix

Including Script in Index.html

Near the bottom of your index.html file ensure you include a script link to your JavaScript file.

  </div>
  <script src="js/widget.js"></script>
</body>
</html>

For Loop

Your for loop was for(var = i; i<employees.length; i+=1). It should look like this:

for(var i = 0; i<employees.length; i+=1){

It was probably just a typo but when using for loops you need to assign a number as a starting index.