title: Toggling an AJAX Response in jQuery
body: <p>So I'm calling on the following AJAX function in order to pull and display specific categorical posts whenever a corresponding button is pushed:</p>
  
  <pre><code>&lt;script&gt;    
  // Brochure AJAX
  
      function term_ajax_get(termID) {
  
          jQuery("#loading-animation").show();
          var ajaxurl = 'http://localhost/kskj-portal/wp-admin/admin-ajax.php';
  
              jQuery.ajax({
                  type: 'POST',
                  url: ajaxurl,
                  data: {"action": "load-filter2", term: termID },
                  success: function(response) {
                      jQuery(".brochure-post-container").append(response);
                      jQuery("#loading-animation").hide();
                      return false;
                      }
              });
          }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>The function is being called upon using the onclick attribute within the HTML in order to update the function's input (termID) dynamically:</p>
  
  <pre><code>&lt;?php foreach ($products as $product):
      // setup the product/cateogory ID
      $product_name = $product-&gt;name;
      $product_id= $product-&gt;term_id;
      $product_slug = $product-&gt;slug;
  
      ?&gt;
  
  
      &lt;div class="product-container OFF" onclick="term_ajax_get(&lt;?php echo $product-&gt;term_id; ?&gt;)"&gt;
  </code></pre>
  
  <p>Is there a way where I can toggle the specific post being displayed? Basically if a button is pushed, its corresponding posts are displayed. If the button is pushed again, the posts are hidden. If one button is pushed, and then another button is pushed, both categories posts display at the same time until one of the buttons is pressed again. </p>
  
  <p>Right now every time a button is being pushed it appends that category's post onto the page. I need to get the category onto the page when pushed, but I don't know how to remove it when its corresponding button is pushed again, or how to add other categories when both buttons are selected.</p>