Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
Thread: Interactive mode and IE
07-19-2007, 03:26 PM #1
- Join Date
- Sep 2006
- Thanked 0 Times in 0 Posts
Interactive mode and IE
I have already asked on the jQuery discussion group about this but as far as I can discern the problem lies in Internet Explorer's XHR implementation and needs to be addressed at that level.
I am working on an AJAX application, and thought it would be a good idea to give the user some indication of data transfer progress as most AJAX apps don't do this and I personally find being made to wait for a download without being kept informed of it's progress frustrating.
I did some reading up and discovered that when the XHR object is in readyState 3 (interactive) then the partial data that has been transferred thus far is available in responseText. I figured that if I can get the server to send an accurate Content-length header and then measure the length of the responseText string at regular intervals I could generate a download progress report. Here's the code I wrote to do this:
var progressElem = $('#progressCounter');
type : 'GET',
dataType : 'xml',
url : 'somexmlscript.php' ,
beforeSend : function (thisXHR)
myTrigger = setInterval (function ()
if (thisXHR.readyState > 2)
var totalBytes = thisXHR.getResponseHeader ('Content-length');
var dlBytes = thisXHR.responseText.length;
(totalBytes > 0)?
progressElem.html (Math.round ((dlBytes / totalBytes) * 100) +
progressElem.html (Math.round (dlBytes / 1024) + "K");
complete : function ()
// Other cleanup code goes here
success : function (response)
// Process XML
According to the page linked to above, you cannot access responseText while in readyState 3, even though the MSDN documentation says that you can.
Am I doing something wrong? Does accessing responseText in readyState 3 require a different syntax in IE? Or is there some other attribute of the XHR object I can access in IE that I can use to generate the download progress report? While the report feature strictly speaking isn't necessary I think it would be a big help to improving the useability of AJAX apps that have to download a big chunk of data.