title: JavaScript 'function invoked' event listener
body: <pre><code>function addAndRemove() {
      if (mapData.initialZoom &amp;&amp; !cameraStatus.locked) {
          cameraStatus.locked = true;
          var ajaxRequest = null;
  
  
          var abortMission = setTimeout(function () {
  
              /* Here is where I need the event listener.
               * If the function is called again then we need to
               * cancel our existing ajax request */
  
              if (ajaxRequest) {
                  ajaxRequest.abort();
                  updatePrompt({text: "Cancelled ajax"});
              }
  
              cameraStatus.locked = false;
          }, 1000);
      }
  }
  </code></pre>
  
  <p>As I have stated in a comment in the code I need to be able to listen out to see if <code>addAndRemove</code> is called again whilst in execution. I only want to cancel the existing Ajax request if a new one has been requested. How can I do this?</p>