I've been working on a website that processes XML files, And I ran into an issue once I added a bit more processing. The issue I am having is in using setTimeout to give the browser a break to 'breathe' so that it doesn't crash trying to load a bunch of information into innerHTML. When I load it, it only loops twice, then returns an error of "VM###:1"(### constantly changes).
var i = 0;
var run = process();
process();
function process(){
if (i < x.length) {
var name = $(x[i]).find("Description[DescriptionCode='DEF']").text();
var ixx = x.length + (20 - (x.length % 20));
var ix = Math.round((i+10) / 20);
var type = "";
var desc = $(x[i]).find("Description[DescriptionCode='DES']").text();
var lamp = desc;
var g = 1;
var id = $(x[i]).find("PartNumber").text();
var ddId = "D" + id + "D"
var price = $(x[i]).find("Pricing[PriceType='RMP']").find("Price").text();
for (n=0;(g == 1) && (n < sType.length); n++) {
if (desc.indexOf(sType[n].type) > -1) {
type = sType[n].type;
lamp = lamp.replace(sType[n].type, '');
g = 0;
}
};
for (n=0;(g == 1) && (n < sVolume.length); n++) {
if (desc.indexOf(sVolume[n].vol) > -1) {
vol = sVolume[n].vol;
lamp = lamp.replace(sVolume[n].vol, '');
g = 0;
}
};
for (n=0;(g == 1) && (n < sYear.length); n++) {
if (desc.indexOf(sYear[n].year) > -1) {
year = sYear[n].year;
lamp = lamp.replace(sYear[n].year, '');
g = 0;
}
};
document.getElementById("productDiv").innerHTML += "The stuff I'm processing goes here.";
i++;
setTimeout("process", 1);
}
};
Aucun commentaire:
Enregistrer un commentaire