The following code:
let s=[[],[]];
let k=0;
while (k<(JSON.parse(req.responseText).length)){
s[k][0] =dataBack[k].ModuleCode;
s[k][1] =dataBack[k].ModuleDescription;
k=k+1;
}
Should populate an array (s) with the data from an Ajax responce. But this is not the case, since when k=2 (3d item) I get an error:
code.js:288 Uncaught TypeError: Cannot set property '0' of undefined
Searching on StackOverflow, I found this link: How to create empty 2d array in javascript? describing what I have done to declare my Array.
I am expecting the above code to store the returned values into the (s) array. But I get the error described above.