, 당신은 집계를 사용할 수 변경하도록 요청 할 수 없습니다
var data; // will contain the retrieved data
/**
* Grab data from the first URL in the list, adding it
* to the global data variable. If the list is empty,
* we got all the data and we succeed. If an XHR fails, we fail.
*/
function prepData(urlList, success, fail) {
if(urlList.length===0) {
succes(); // wrap in timeout if you need to break out of call chain
return;
}
var xhr = new XMLHttpRequest();
var url = urlList.splice(0,1)[0];
xhr.open("GET", url, true);
xhr.onreadystatechange = function() {
if (xhr.status === 200 && xhr.readyState === 4) {
data += xhr.responseText;
prepData(urlList, success, fail);
} else {
fail(urlList, xhr); // again, wrap in timeout to break out of call chain
}
}
}
우리는 다음과 같은 코드로이를 호출 할 수
/**
* prepare our data prior to application "start"
*/
prepData(['...','...','...'], function(){
console.log("finished aggregating data");
// all went well. Start the actual data-consuming code
}, function(notLoadedList, failedXhrObject){
console.log("ohnoes!", notLoadedList, failedXhrObject);
// something went wrong, and we can fail gracefully
});
"웹 서버에서 거대한 멀티 csv 파일을 다운로드하고 그것을 열기 전에 클라이언트 측에서 그 부분에 가입 사용자 "는 이것을하지 않는 것이 많은 이유입니다. 사용자가 거대한 데이터 세트를 다운로드해야하는 경우 솔루션이 올바른 솔루션이 아닙니다. 클라이언트가 실제로 사용자가 볼 수있는 비트 만 서버에 요청하게하고, 거대한 한 번에 모든 데이터가 필요하지 않고 코드를 작성하여 처리하십시오. –
더 이상 당신에게 동의 할 수 없습니다. 그러나 응용 프로그램은 이미 있습니다. 오늘날 사용자는 수동으로 파일을 병합합니다. 나는 그 부분을 자동화하려고하고있다. – user2102619