What looks strange to me is that you use request = $.ajax()
without var
which means you override the next higher definition of request
. If none is defined it will be in the global scope (window.request
).
This could cause problems.
Rewrite it like:
$(".downloads a").each(function() {
var link = $(this);
$.ajax({
type: "HEAD",
url: link.attr("href"),
success: function(data, textStatus, request) {
var length = request.getResponseHeader("Content-Length");
if (!isNaN(parseInt(length))) {
var fileSize = readablizeBytes(length);
var type = link.attr("href").split('.').pop();
var text = link.html();
link.html(text+'<span class="info">'+type+' - '+ fileSize +'</span>');
}
}
});
});
Although I can't reproduce your problem in any way.