JavaScript ajaxComplete not firing to stop script

I'm stuck on a making a simple loading function for an AJAX request. AJAX is still pretty new to me, so I'm sure I'm just doing something dumb!

ajaxStart fires and starts loading the spinner.gif, but ajaxComplete doesn't fire and the gif keeps on spinning even after the second page's results have loaded after a delay of 1 second. Jquery is loaded and the ajax load of the second page works fine - its just stopping this loading gif from playing once the load function is done! Any ideas anyone? Thanks!

<script>
$(document).ready(function() {

$(document).ajaxStart(function(load_a){
    $("#wait_a").css("display", "block");
});


$(document).ajaxComplete(function(load_a){
    $("#wait_a").css("display", "none");
});


var load_a = function () {
    setTimeout(function(){
        $('#ajax_content_a').load('http://localhost/a.php');},1000);
        alert(exception);
}


load_a();


});
</script>

<div id="ajax_content_a">Loading...</div>
<div id="wait_a" style="display:none;width:120px;height:120px;border:0px;position:absolute;top:50%;left:50%;padding:2px;"><img src='http://localhost/loading_spinner.gif' width="120" height="120" /></div>
Answer:1

I'm trying to attach onclick events to elements created dynamically, but only the last element captures the event, ... why? Here the code: <!DOCTYPE HTML> <html> <head><title&...

I'm trying to attach onclick events to elements created dynamically, but only the last element captures the event, ... why? Here the code: <!DOCTYPE HTML> <html> <head><title&...

  1. dynamically creating elements in javascript
  2. react dynamically generated elements
  3. jquery dynamically generated elements events
  4. jquery loop through dynamically generated elements
  5. jquery select dynamically generated elements

I want to create a new ObjectId in the mongo shell but for a Date in the past in order to simulate the creation ob this document in the past. That would be the opposite of the getTimestamp() function ...

I want to create a new ObjectId in the mongo shell but for a Date in the past in order to simulate the creation ob this document in the past. That would be the opposite of the getTimestamp() function ...

  1. create objectid from string
  2. create objectid in mongoose
  3. create objectid in mongodb

I'm having a little difficulty programming the DateTextBox widget to operate with a month and year only input, and to put a mm/yy format in the DateTextBox. Can anyone help me tidy this up? <...

I'm having a little difficulty programming the DateTextBox widget to operate with a month and year only input, and to put a mm/yy format in the DateTextBox. Can anyone help me tidy this up? <...

I have come across a self executing function that executes on a condition that the declared containing var exists, and if it doesn't exist it is passed an object. Example: var myFunc = (function(...

I have come across a self executing function that executes on a condition that the declared containing var exists, and if it doesn't exist it is passed an object. Example: var myFunc = (function(...

  1. self executing function javascript
  2. self executing function js
  3. self executing function es6
  4. self executing function jquery
  5. self executing function typescript
  6. self executing function python
  7. self executing function
  8. self executing function php
  9. self executing function javascript example
  10. self executing function vs document ready
  11. self executing function javascript jquery
  12. self executing function servicenow
  13. self executing function parameter
  14. self executing function angular
  15. self executing function c#
  16. self executing function expression
  17. self executing anonymous function
  18. self executing arrow function
  19. self executing async function
  20. anonymous self executing function javascript