0

I need to get the header information from a JQuery load call before the page finishes loading.

Background information, I am using load() to load content into a portion of the page, however when the connection is slow it appears that the system is "froze" when it hasn't.

solution : Get the file size from the file being loaded before it is loaded and showing a status bar on screen showing how quickly it is loading.

Any suggestions?

Neo
  • 2,305
  • 4
  • 36
  • 70
  • 1
    Perhaps this question might help? http://stackoverflow.com/questions/4715223/ajax-head-request-via-javascript-jquery – Dogoku Apr 15 '13 at 10:54
  • Kind of helps but I was hoping for a single call to reduce bandwidth, also it wouldn't allow the current bytes loaded to be calculated – Neo Apr 15 '13 at 11:44

1 Answers1

0

Very simple example, based on answer from Ajax HEAD request via Javascript/jQuery

$.ajax({
    type: "HEAD",
    async: true,
    url: '/',
    success: function(message,text,response){
        console.log(response.getResponseHeader('Content-Length')]);
    }
});
Community
  • 1
  • 1
Dogoku
  • 4,585
  • 3
  • 24
  • 34
  • 1
    This won't solve the problem. While it gets the file size, you then have to make another request to get the file itself, and then you still have the problem of determining how much of the file has loaded so you can compare it to the total length. – Quentin Apr 15 '13 at 11:04