我需要对第一个 XHR 执行条件检查,如果满足条件,则执行第二个 XHR,它将使用设置请求标头来限制范围。
function getData( url )
{
if (y==0) {
alert ("you set vaue of y to 1");
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if ( request.readyState == 4 ){
renderData( request.responseText );
request.open( "GET", "TheData.csv", true );
//request.send( null );
y = 1;
}
}
} else {
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if ( request.readyState == 4 ){
renderData( request.responseText );
request.open( "GET", "TheData.csv", true );
//request.send( null );
request.setRequestHeader("Range", "bytes=" + BytesRead + "-");
}
}
}
}