2011-07-14 22:22:54 +00:00
|
|
|
|
|
|
|
jQuery.ajaxPrefilter(function(options, _, jqXHR) {
|
|
|
|
|
|
|
|
if (jQuery.isFunction(options.progress)) {
|
|
|
|
|
|
|
|
var xhrFactory = options.xhr,
|
|
|
|
interval;
|
|
|
|
|
|
|
|
options.xhr = function() {
|
|
|
|
|
|
|
|
var xhr = xhrFactory.apply(this, arguments),
|
|
|
|
partial = "",
|
|
|
|
prevcount = 1;
|
|
|
|
|
|
|
|
interval = setInterval(function() {
|
|
|
|
|
|
|
|
var responseText,
|
|
|
|
jQueryPartial;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
responseText = xhr.responseText;
|
|
|
|
|
|
|
|
if (responseText && (responseText.length > partial.length))
|
|
|
|
{
|
|
|
|
|
|
|
|
partial = responseText;
|
|
|
|
jQueryPartial = $(partial).filter("*")
|
|
|
|
|
|
|
|
if (jQueryPartial.length > prevcount) {
|
|
|
|
prevcount = jQueryPartial.length;
|
|
|
|
options.progress(jQueryPartial.filter("*:not(:last)"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch(e) {
|
2011-09-25 18:25:09 +00:00
|
|
|
if (window.console)
|
|
|
|
console.log(e);
|
2011-07-14 22:22:54 +00:00
|
|
|
}
|
|
|
|
}, options.progressInterval);
|
|
|
|
|
|
|
|
return xhr;
|
|
|
|
};
|
|
|
|
function stop()
|
|
|
|
{
|
|
|
|
if (interval)
|
|
|
|
clearInterval(interval);
|
|
|
|
}
|
|
|
|
jqXHR.then(stop, stop);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|