I'm having issues with the <progress> tag in Chrome (using it in the indeterminate state). It animates perfectly fine at first, until I shoot off an XMLHttpRequest, at which point the progress element stops animating. Once the XMLHttpRequest is finished, the progress element starts animating again.

This issue doesn't happen in Firefox - in Firefox the progress element continues to animate during processing of the XMLHttpRequest.

As far as I can tell, this must be a threading issue in Chrome - does anyone know of a workaround for this? Any help would be appreciated, or even just confirmation that I haven't stuffed something up Smile

Here's the relevant code, which works perfectly fine in Firefox, but not Chrome.

The JavaScript portion (using jQuery):

Code:
    function process() {
        $("#start").val("Processing...");
        $("#start").attr("disabled", "disabled");
        $("#pbar").show();
        setTimeout(function() {
            if (window.XMLHttpRequest) { // ie7+, firefox, chrome, safari, opera
                xmlhttp = new XMLHttpRequest();
            } else { // ie6, ie5
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.open("GET", "/process/generateProdOrders.asp?f=" + $("#from").val() + "&t=" + $("#to").val(), false);
            xmlhttp.send();
            var xmlDoc = xmlhttp.responseXML;
            var numOrders = parseInt(xmlDoc.getElementsByTagName("orders")[0].childNodes[0].nodeValue);
            $("#result").append("<br />" + numOrders + " orders generated");
            $("#pbar").hide();
            $("#start").val("Done");
        }, 50);
    }

And the HTML portion:

Code:
    <input type="button" id="start" value="Start" onclick="process()"><br />
   
    <progress id="pbar" style="display: none;">Processing orders...</progress><br />
I'd personally chalk it up to a Chrome bug. I don't think I'd recommend using the <progress> element too heavily anyway, though, since it's HTML5-specific and only recent Firefox and Chrome versions (and very recent IE versions) support it.
KermMartian wrote:
I'd personally chalk it up to a Chrome bug. I don't think I'd recommend using the <progress> element too heavily anyway, though, since it's HTML5-specific and only recent Firefox and Chrome versions (and very recent IE versions) support it.


Mmm I figured it might be a Chrome issue that I can't really get around. It's no big deal I guess at this stage anyways, this is just a small section of the staff web portal I'm building at work, and this <progress> element only runs anywhere between 5 - 30 seconds, depending on how many orders there are to process. It was more just to let the user know that something is happening in the background. There are other ways I can deal with it for now Smile
How about showing and hiding a simple animated spinner GIF? It's not very HTML5, but it works. Smile
That would definitely do the job, providing that Chrome didn't pull the same trick and stop animating the GIF whilst it's waiting for the XMLHttpRequest results.. I'll give it a try this afternoon if I get a chance Smile Thanks Kerm!

EDIT: Chrome, you are a fickle thing.. It stops animating the gif whilst it's waiting on the XML data. I even tried having the <div> that contains the gif image visible at all times, and the page loaded with the gif animating, then as soon as the XMLHttpRequest is started, the gif pauses, then resumes a few seconds later when the data returns.

Oh well, it was worth a try!
not too sure, but i remember the last parameter as being a synchronous/asynchronous toggle? could try to fiddle with that?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement