title: AJAX response caching / onclick-event inside of a function
body: <p>I´m using AJAX to execute some server-side actions and refresh a table inside the page without reloading the page itself. All works fine at first view. But I wrote a function in PHP to send an email and execute it via AJAX. When I´m starting this action for a second time old responses gets triggered.</p>
  
  <p><em>What exactly happens:</em></p>
  
  <ul>
  <li>I´m clicking a Button to execute the "Sendmail-Action"</li>
  <li>a Modal asks me if I want to execute the action and I´m clicking yes</li>
  <li>a PHP-Script gets executed and sends the email</li>
  <li>the Modal gets closed after the PHP-Script finishes (~2s)</li>
  <li>the table (with emails and so on) gets refreshed and the status updated</li>
  </ul>
  
  <p><em>What happens next:</em></p>
  
  <ul>
  <li>I´m clicking a Button to execute the "Sendmail-Action" for the same
  or another entry in my table</li>
  <li>a Modal asks me if I want to execute the action and I´m clicking yes</li>
  <li>the Event triggers twice / 4xAjax-Request instead of 2 (I can see it in my Chrome-Console)</li>
  <li>the Modal closes and 2 Mails sended</li>
  </ul>
  
  <p><em>What I´ve tried to get rid of this behaviour:</em></p>
  
  <ul>
  <li>checked my JS with JSHint</li>
  <li>checked my PHP-Code (no errors in apache error.log)</li>
  <li>redesigned the PHP-Script (Sendmail), now the AJAX executes a function</li>
  <li>tried different browsers</li>
  <li>deactivated AJAX-Caching</li>
  <li>completely deactivated Caching with Apache (correct Headers)</li>
  <li>deactivated Session-Caching in my php.ini (I don´t use sessions)</li>
  <li>unset all variables in PHP</li>
  <li>cleared the cache for all of my browsers</li>
  <li>checked all headers</li>
  <li>searched several hours for solutions</li>
  </ul>
  
  <p><em>More information about my setup:</em></p>
  
  <ul>
  <li>jQuery 2.1.4 </li>
  <li>php 5.4</li>
  <li>Apache 2.2</li>
  </ul>
  
  <p>I can´t find a solution to my problem and maybe this is caused because I´m adding the content dynamically to the table. I had the same problem in the past and I´m thinking the Modal (which is also dynamic) triggers the click on the "Yes-Button" twice.</p>