title: Why is my jquery ajax requests performing multiple times?
body: <p>I am looking at the console in firebug when I click on a function which performs an ajax request. The problem is, that one click of a button should send 1 ajax request, but I get 2 requests being sent!</p>
  
  <p>The code for my js looks like this:</p>
  
  <pre><code>$(document).ready(function() {
     $('.book_now').click(function(){
  
  
  $.ajax({
    type: 'POST',
    url: '/booking.php',
    data: 'event_id='+event_id+'&amp;time_id='+time_id,
    success: function(data) {
      console.log('inside');
      $('#booking_box_content').html(data);
    }
  });
  
  
    });
  });
  </code></pre>
  
  <p>Which seems pretty straight forward right?</p>
  
  <p>In my console however, I see 2 x GET requests off 1 click.</p>
  
  <p>My button is simply:</p>
  
  <pre><code>&lt;div class="book_now"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Am I missing something - is there supposed to be 2 GET requests? </p>
  
  <p>Is it by any chance loading up the $(document).ready() function again when the new file is loaded and therefor executing the click function again?</p>
  
  <p>Note: I'm not double clicking the button. It probably doesn't matter, but if I change it to POST it does it twice also. </p>
  
  <p>Edit: the response from booking.php</p>
  
  <pre><code>&lt;div id="booking_box_left"&gt;
    &lt;h1 class="speaker_name"&gt;&lt;/h1&gt;
    &lt;h1 class="event_name"&gt;&lt;/h1&gt;
  
    &lt;div class="event_start_header"&gt;Start&lt;/div&gt;&lt;div id="event_start_datetime"&gt;, &lt;/div&gt;
    &lt;div class="cleared"&gt;&lt;/div&gt;
    &lt;div class="event_end_header"&gt;End&lt;/div&gt;&lt;div id="event_end_datetime"&gt;, &lt;/div&gt;
    &lt;div class="cleared"&gt;&lt;/div&gt;
    &lt;div class="event_where_header"&gt;Where&lt;/div&gt;&lt;div id="event_where"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;
  &lt;/div&gt;
  
  &lt;/div&gt;
  &lt;div id="booking_box_right_container"&gt;
    &lt;form id="booking_form_1" method="post"&gt;
      &lt;input type="hidden" name="booking_id" value="7a614fd06c325499f1680b9896beedeb" /&gt;
      &lt;input type="hidden" name="event_id" value="" /&gt;
      &lt;input type="hidden" name="time_id" value="" /&gt;
      &lt;div id="booking_box_right"&gt;
        &lt;h1&gt;To reserve your seat&lt;/h1&gt;
        &lt;input type="text" name="booking_email" class="enterSomething booking_email" title="Enter your email..." /&gt;
        &lt;div class="booking_email_helper"&gt;On clicking next a ticket will be held for you for a short period for you to complete your registration.&lt;/div&gt;
        &lt;input type="submit" id="next" value="Next" /&gt;
      &lt;/div&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Note: nothing in this response has any functions being triggered to my knowledge. I'm skeptical that the response is what is firing off the ajax request twice... if the click function is only running once, then it can't possibly be the button is executing the function twice, but the $.ajax() part, namely the success callback which is. I've updated the JS code to show how I structured the console.log() stuff.</p>
  
  <p><strong>FINAL EDIT:</strong></p>
  
  <p>My ajax function was wrapped inside of the following:</p>
  
  <pre><code>   $('#shade, #booking_box').fadeIn(function(){
  
       // ajax function
  
    }
  </code></pre>
  
  <p>I had no idea but it was calling this function for for when the #shade (my thickbox) and the #booking_box came in hence running it TWICE! :(</p>
  
  <p>I feel like such a tool.</p>
  
  <p>Thanks everybody for your help. </p>