0

Basically i´m getting data from two external sources and i wish to compare both.

First i´m getting data from a XML using Ajax and put it in a Array inside a Array:

var Array1 = []; //outside Ajax
...
var valueToPush = new Array();
valueToPush[0] = zz;
valueToPush[1] = aa;
Array1.push(valueToPush);

Then i´m getting a post from a PHP file that i scrapped from a HTML file, meanwhile i´m trying to compare both data from XML and from the scrapped HTML (using date time), also using a if statement to limit the search:

if (lng < (-18)) {

for(var i=0, len = Array1.length; i<len; i++) {

var date1 = Array1[i][1];

if (date2 == date1) {

alert("equal");
}

else {
//do something else
}
}
}

Well Firefox starts getting >1GB of Ram and the browser crash (sometimes i can stop the script). The problem (i think) is in the "for(var i=0, len = Array1.length; i

Anyone can point me out a solution?

Thanks

Edit: Live version of the site crashing. Removing from 435-449..resolves the issue of crashing, but doesnt compare data. http://preview.tinyurl.com/mf9g9fq

Edit2: Following the comments, i edited the code to a much simpler version. It has two tables, one return the events from the scrapped HTML "if long < 18", the other table return the events "long > 18". Uncommenting 183 - 200 will make the browser crash. Notice after uncommenting, in the first table it will repeat infinitely the first result "if long < 18".

Working but commented - http://preview.tinyurl.com/mf9g9fq

Crashing uncommented - http://preview.tinyurl.com/m59p4wf

Edit3 Following Crazy Train user suggestion, i replaced a i with another letter ex j in a for, and it solved my problem! Explanation of the cause of this is in the below comments. Thanks Crazy Train!

4

0 回答 0