Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript AJAX Basics (retiring) jQuery and AJAX Introducing jQuery

Ben Ahlander
Ben Ahlander
7,528 Points

why is the button not hiding?

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>AJAX with JavaScript</title>
  <link href='http://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
  <link rel="stylesheet" href="css/main.css">
  <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>


  <script>

  function sendAJAX() {
    $('#ajax').load('sidebar.html');
    $('#ajax').hide();

  }

  </script>
</head>
<body>
  <div class="grid-container centered">
    <div class="grid-100">
      <div class="contained">
        <div class="grid-100">
          <div class="heading">
            <h1>Bring on the AJAX</h1>
          </div>
          <button id="load" onclick="sendAJAX()" class="button">Bring it!</button>
          <div id="ajax">

          </div>
        </div>
      </div>
    </div>
  </div>
</body>
</html>

3 Answers

Arien Woodrow
Arien Woodrow
7,222 Points

The button's id is load not ajax so $('#load').hide();

ywang04
ywang04
6,762 Points

The id of button is "load" instead of "ajax".

 $('#ajax').hide();  //change it to "load"

 $('#load').hide();

try to put it in a click function like this $( "ajax" ).click(function() { $( this ).hide(); });

Hope this helps : )