1
有什麼辦法可以在使用Mootools請求時下載「迄今爲止」下載的輸出? 我知道那裏有「onProgress」,但是這隻給我下載的字節。Mootools請求跟蹤進度輸出
正在下載的頁面是電子郵件地址列表,並且對於已發送的每封電子郵件,該頁面會在該頁面附加一行直到其完成執行。
我想採取最新的線,並呈現給用戶,作爲進步的推移...
有什麼辦法可以在使用Mootools請求時下載「迄今爲止」下載的輸出? 我知道那裏有「onProgress」,但是這隻給我下載的字節。Mootools請求跟蹤進度輸出
正在下載的頁面是電子郵件地址列表,並且對於已發送的每封電子郵件,該頁面會在該頁面附加一行直到其完成執行。
我想採取最新的線,並呈現給用戶,作爲進步的推移...
mootools的僅支持什麼WebKit和壁虎的支持(現在也許IE9/10)。
onLoadstart(event, xhr)
onProgress(event, xhr)
進度事件 - 如果可用 - 應該足以讓你走。有關可用的規範,請參閱https://dvcs.w3.org/hg/progress/raw-file/tip/Overview.html。
http://jsfiddle.net/dimitar/tYdjN/
var list = [],
len = 10000,
loaded = $('loaded'),
output = $('output'),
count = 168,
chunks = 0;
while(len--)
list.push(Faker.Internet.email());
list = list.join('<br/>\n');
new Request({
url: '/echo/html/',
data: {
html: list
},
onProgress: function (event, xhr) {
chunks++;
loaded.set('html', event.loaded + ' bytes');
new Element('h4[html=Chunk ' + chunks +']').inject(output);
new Element('div.chunk', {
html: xhr.response,
styles: {
background: ['rgb(', count, ',', count,',', count, ')'].join('')
}
}).inject(output);
count -= 16;
},
onComplete: function(){
//console.log(this.response.text);
// $('list').set('html', this.response.text);
}
}).send();
這個例子是使用的jsfiddle的AJAX API,我使用Faker.js產生10000個隨機電子郵件 - whihc的jsfiddle發回給我塊。每個塊在一個div中輸出它自己的電子郵件。