javascript - While loop crashes with certain mathematical functions in jquery -



getting array php using ajax. in ajax, want break down array put parts divs.
made code here selects parts fit , put them there:

while (array[x] != null) {   y = 0;   if (2 < x) {     if (x == 3) {       x = 0;       y = x;     } else {       y = x / 2     }   }   settimeout(function() {     if (y == 0 || x % 3 === 0) {       var namestring = array[y];       var namestring = array[y].replace('[', '');       var namestring = namestring.replace('[', '');       var namestring = namestring.replace('"', '');       var namestring = namestring.replace('"', '');     }     if (y % 2 != 0 || y % 3 != 0 && x > 0) {       alert(y);       var date = array[y]       var date = date.replace('"', '');       var date = date.replace('"', '');     }     if (x % 2 == 0 && x > 0) {       var text = array[y];       var text = text.replace('"', '');       var text = text.replace('"', '');       var text = text.replace("]", '');       var text = text.replace("]", '');        createcard(namestring, date, text);     }   }, 500);   if (x > 500) {     break;   };   x = x + 1; } 

the problem part:

if(2 < x) {     if (x == 3) {         x = 0;         y = x;         } else {             y = x/2     } } 

causes program crash. if not have it, works fine. also, if not have problem doesn't work. why happening?
thanks!

i solved it!

while (array[y] != null) {                 if (y == 0 || y % 3 === 0) {                     alert(y);                     var namestring = array[y];                     alert(namestring);                     var namestring = namestring.replace('[','');                     var namestring = namestring.replace('[','');                     var namestring= namestring.replace('"', '');                     var namestring= namestring.replace('"', '');                     y++;                     }                 if (y % 2 != 0 || y % 3 != 0 && x > 0) {                     var date = array[y]                     var date = date.replace('"', '');                     var date = date.replace('"', '');                     y++;                 }                 if (y % 2 == 0 && y > 0) {                     var text = array[y];                     var text = text.replace('"', '');                     var text = text.replace('"', '');                     var text = text.replace("]", '');                     var text = text.replace("]", '');                     y++;                      createcard(namestring,date,text);                 }             if (y > 500) {                 break;             };               } 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -