To properly display a "loading" image in my application, I made the following script:
var spinnerVisible = false;
function ShowProgress() {
if (!spinnerVisible) {
$('div#layer').fadeIn("fast");
$('div#spinner').fadeIn("fast");
spinnerVisible = true;
var spinner = $('#spinner');
spinner.html('<span>Loading, please wait...</span><img src="/Content/ajax-loader.gif" width="250" height="250"/>').css('background', '#fff').show();
}
}
The ajax-loader.gif
image is loading fine in internet explorer and Chrome, but it does not load in Firefox?
EDIT
I have obtained the url of the image, which goes like this:
http://localhost:63779/Content/ajax-loader.gif
If I copy-paste the url in firefox, the gif is loading, but now when the function is called...?
EDIT 2
I don't know if it is related, but I have found this:
jQuery html() in Firefox (uses .innerHTML) ignores DOM changes<
Maybe it is related to my problem?
EDIT 3
Ok, so something strange happened, which I don't really like, but here goes:
Firs I have tried this:
var element = document.getElementById('spinner');
element.setAttribute("'<span>Loading, please wait...</span><img src=\"/Content/ajax-loader.gif\" width=\"250\" height=\"250\" background=\"#fff\"/>')", element.innerHTML);
alert(document.getElementById("spinner").innerHTML);
As I tested in firefox it gave me an error saying that there were illegal characters in my string. So I put the element.setAttribute
line in comments and I got the proper alert...
And the gif showed!
But that's not all: sometimes it plays, sometimes it does not. I'm slightly confused right now, I don't understand why.