I created a jquery utility, that when you select a state from a drop down, it automatically shows the states. To make the user experience better, I added some logic to divide the stores across three columns. This is working correctly in every browser except IE.
I am not sure that the error displayed in the console is the same error that is causing the .change() event to not trigger in IE, but I thought I would mention it. The console error that I am getting is:
Uncaught TypeError: Cannot read property ‘store_url’ of undefined
Here is the code:
else if (store_remainder === 0) {
for(var i = 0; i < check; i++) {
store_col_1.append("<li class='current_store'><a href='" + data[i].store_url + "'>" + data[i].store_name + "</a></li>");
}
for(var i = check; i < (check * 2); i++) {
store_col_2.append("<li class='current_store'><a href='" + data[i].store_url + "'>" + data[i].store_name + "</a></li>");
}
for(var i = (check * 2); i <= data.length; i++) {
store_col_3.append("<li class='current_store'><a href='" + data[i].store_url + "'>" + data[i].store_name + "</a></li>");
}
}
The error comes up only in the final “for” block, which makes me believe that it tries to run the last iteration but doesn’t get a value and comes back as null. If this is the case, how can I fix this?
This:
must be:
as
somearray[somearray.length]is alwaysundefined.