arrays - Javascript Variable Scope - Values Not Assigning -


i'm working on calendar application , i'm having trouble setting values globally declared variables , accessing values in function.

here of code. if need more please comment , can paste all

var eventhold = []; var eyears = []; var emonth = []; var eday = []; var events;  var loaddata = function() {   $.ajax({     type: "post",     url: "getevents.php"   }).done(function(data) {      events = json.parse(data); //returning json object      (i = 0; < events.length; i++) {       eventhold[i] = events[i].edate; //returns 2015-06-15 each object        eyears[i] = eventhold[i].substring(0, 4); //trims 2015       emonth[i] = eventhold[i].substring(5, 7); //trims 06       emonth[i] = parseint(emonth[i]); //change int       emonth[i] --; //decrement 0 base       eday[i] = eventhold[i].substring(8, 10); //trims 08       eday[i] = parseint(eday[i]); //change int     }    }); }  function test() {   firstday = new date(odate.cyear, odate.cmonth, 1); //return date "current year/ current month"   numday = firstday.getday(); // find starting day calendar offset    console.log(eyears.length);   // var times = eyears.length;   // console.log(times);    (i = 0; < eyear.length; i++) {     console.log("first for");     if (odate.cyear == eyears[i] && odate.cmonth == emonth[i]) //none of these values registering. again works in console.     {       console.log("inside if");       $("#day" + eday[i + numday]).append(events[i].ename + "<br>" + events[i].etime); //adding numday match calendar "offset"     }   } } 

when paste loop in console works , outputs fine. can't of values function. appreciated. let me know if unclear , can paste more code i'm hoping not overwhelm.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -