I encountered a puzzling issue with my JavaScript code – it works flawlessly in Google Chrome 49.0.2623, but causes my entire file to crash in Explorer 11. The problem arises when I attempt to 'Export' JavaScript objects using AJAX. Let me share the snippet of code in question:
When running in Chrome:
function AjajPostComponentLists()
{
var myFileContent = new Uint8Array();
var aList1 = {FixedItems:1, List:["None", "Relay #1", "Relay #2"]};
var aList2 = {FixedItems:1, List:["None", "Input #1", "Input #2", "Input #3", "Input #4", "Input #5"]};
var aList3 = {FixedItems:1, List:["None", "Door #1", "Door #2"]};
// ... (I won't list them all)
myFileContent = JSON.stringify({aList1, aList2, aList3});
// ...
}
The resulting output is as follows:
{"aList1":{"FixedItems":1,"List":["None","Relay #1","Relay #2"]},"aList2":{"FixedItems":1,"List":["None","Input #1","Input #2","Input #3","Input #4","Input #5"]},"aList3":{"FixedItems":1,"List":["None","Door #1","Door #2"]}}
However, when attempting to run this in Explorer 11, an error message surfaces:
SCRIPT1003: ':' expected
Interestingly, the error citation points towards the ternary operator, which seems unrelated.
I made an alternate tweak by replacing curly brackets with square brackets and managed to bypass the error, albeit sacrificing certain attributes like object names in the process.
What could be causing this discrepancy between Chrome and IE? Any insights would be greatly appreciated.
Thank you!