我从文件中获取json数据并在每个循环中创建另一个json文件,并在此处发送对json文件的请求是我创建json文件的代码
var derivatedFeatures = ["RMS","sb2xMagnitudev_ipspeak", "sbSubsynchronousv_ipspeak", "PeakPeak_mil", "sbHighFrequency_grms", "TruePeak_ips", "PeakPeak_g", "sb1xMagnitudev_ipspeak","Crestfactor"];
$.each(derivatedFeatures,function(index,feature){
$.each(data,function(index,item){
var featurefile ="Lines_"+feature+'_'+item['Line']+'_'+item['Component'].split(" ").join("_")+'.json'
filedata = {
file:featurefile,
site:item['Site'],
area:item['Area'],
line:item['Line'],
equipment:item['Equipment'],
component:item['Component'],
feature:feature
};
frank.sendAjax('/static/data/json/'+featurefile,'', 'GET', anomaliesDataAppend,filedata);
});
});
并继续处理
执行此操作的原因
答案 0 :(得分:1)
我希望这有助于你: 这是我为您的解决方案编码
$.each(derivatedFeatures,function(index,feature){
$.each(data,function(index,item){
indexnum++;
var featurefile ="Lines_"+feature+'_'+item['Line']+'_'+item['Component'].split(" ").join("_")+'.json'
filedata.push({file:featurefile,
site:item['Site'],
area:item['Area'],
line:item['Line'],
equipment:item['Equipment'],
component:item['Component'],
feature:feature,
indexnum:indexnum
});
});
});
loadFeatureFiles(filedata,0);
var loadFeatureFiles = function(filedata,indexnum){
var startfrom=indexnum;
var endto=startfrom+10;
for (var i=startfrom;i <= endto;i++) {
requestdata={filedata:filedata[i],indexnum:i};
frank.sendAjax('/static/data/json/'+filedata[i]['file'],'', 'GET', anomaliesDataAppend,requestdata);
};
};
分配data = rows,当用户向下滚动并传入函数
时获取//data is induxnum
loadFeatureFiles(filedata,data);