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) jQuery and AJAX Add a callback

Emily Bly
Emily Bly
9,437 Points

I don't know what I'm doing wrong (AJAX callback/get method).

I keep getting the following error message :"jQuery's html() method isn't in your script. To use it, add a period to a jQuery object, like this: $('#footer').html();". What am I doing wrong?

app.js
$.get("footer.html", function(response){
  $('#ajax').html(response);
  $('#footer').select;
  $('#footer').html(response);

 });
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>AJAX with JavaScript</title>
</head>
<body>
  <div id="main">
    <h1>AJAX with jQuery</h1>
  </div>
  <div id="footer"></div>
  <script src="jquery.js"></script>
  <script src="app.js"></script>
</body>
</html>

2 Answers

Steven Parker
Steven Parker
231,172 Points

You've got some extra stuff in your function that is probably confusing the validation. The first two lines are doing things that were not asked for by the instructions. And I don't think the second line is actually a valid jQuery statement. Just remove those and you should pass the challenge.

In general, you'll get the best results from the challenges by following the instructions and not doing anything "extra".

Emily Bly
Emily Bly
9,437 Points

It worked. Thanks!

I had the extra code because it was part 3 of the challenge. Usually, it says to add to the existing code. It seemed superfluous to me as well.

Steven Parker
Steven Parker
231,172 Points

Glad I could help. And it's possible you may have misunderstood some part of the instructions. After following all 3 task instructions and not removing anything, the function body should have only one line.