1

I found this answer How to show loading spinner in jQuery? and used it for my "waiting" spinner. Works perfectly in Firefox, but does not work at all in chrome. I am using jquery cdn from google, version 1.11.1. here is the code for my .ajaxStart/Stop:

var $loading = $('#loading').hide();
$(document).ajaxStart(function() {
    $loading.show();
    $('#buy').attr("disabled", true);
    $('#process').attr("disabled", true);
})
.ajaxStop(function() {
    $loading.hide();
});

How do I get it to work in all the browsers? I am running the latest version of chrome Version 38.0.2125.111 m

EDIT: Here is the div that my spinner lives in:

<div id="loading">
        <img src='../images/loading.gif' />
    </div>

Not sure if that is relevant or not but wanted to give as much info as I could. Just for yuks, I added alerts to the start and stop functions, and they both fire as expected. When the alert in the stop function fires, my spinner is there. If that is the case, why does it not show as expected?

Community
  • 1
  • 1
Jim
  • 1,295
  • 3
  • 17
  • 43
  • Try to provide us with a JSFiddle or something similar reproducing your problem. – AsTeR Nov 06 '14 at 13:47
  • I cannot post the program that I am using this on as it is password protected and uses proprietary formulas... Sorry. – Jim Nov 06 '14 at 13:48
  • `.attr("disabled", true);` should be `.prop("disabled", true);` – j08691 Nov 06 '14 at 13:49
  • @j08691 that is not the problem. Neither is the code shown. Problem is elsewhere. Any message in FX console? – mplungjan Nov 06 '14 at 14:01
  • nothing! works perfectly in Firefox, no messages in the developer tools in chrome either. – Jim Nov 06 '14 at 14:11
  • Works in Chrome for me: http://jsfiddle.net/mplungjan/q4jtjwjq/ – mplungjan Nov 06 '14 at 14:35
  • @mplungjan - I never said that was the problem that would solve the question, just that he should be using prop over attr. – j08691 Nov 06 '14 at 14:35
  • @mplungjan It works in chrome for me as well, one question, why the delay? and if that is the solution, where should I put it and how will it affect FireFox? – Jim Nov 06 '14 at 14:46
  • The delay is to pretend to go and get data - ignore it. Your issue is elsewhere in your code, possibly in the ajax call itself. Try console log inside the ajaxStart and ajaxStop to see they are reached – mplungjan Nov 06 '14 at 15:09
  • I put alerts in both of them and they did fire. the ajaxStop actually showed my spinner until I closed the alert box. Not sure what that means. – Jim Nov 06 '14 at 15:13

1 Answers1

2

Here is the final solution to this in case any one else stumbles into the same predicament. After reading every post on SO that i could find, it came down to this: remove any reference to async: false since it has been deprecated.

Hope this helps someone else in the future.

Jim
  • 1,295
  • 3
  • 17
  • 43