title: Button onclick ajax call
body: <p>I am trying to put together a webpage that has multiply pages in 1 file which checks the session that i've created to show a page according to the session value. <br>
  However, i want to create a button that does a ajax call on the background and returns the results thought JSON, BUT i don't know if i'm doing it the right way. <br>
  I have this js:</p>
  
  <pre><code>$(document).ready(function() {
  var alert = $('.Cmessage'); // DIV TO PUSH RESULTS TO
  
  $("#terug").on('click', function(){
  
  $.ajax({
    url: 'http://www.XXX.nl/shop/offerte/back.php', // form action url
    type: 'get', // form submit method get/post
    dataType: 'json', // request type html/json/xml 
    beforeSend: function() {
      alert.fadeOut();
    },
  success: function(result) {
      if(result.error){
          alert.html(result.html).fadeIn();
          console.log(e)
      }else{
          alert.html(result.html).fadeIn();
          }
      }
  });
  });
  });
  </code></pre>
  
  <p>This js needs to check whenever i click on:</p>
  
  <pre><code>&lt;button type="button" class="terug"&gt;Open/Laden&lt;/button&gt;
  </code></pre>
  
  <p>But somehow i fail to get it attached to the class "terug" and do something with it. </p>
  
  <p>Does anybody has any suggestions/idea's on how i can do this better and get it working ? :P </p>
  
  <p>Greetings.</p>