I'm adding i18n support to an old javascript component. It didn't need xhr/fetch before, but it does still need to work in IE11.
I wan't to write:
fetch("/libs/cq/i8n/dict." + lang + ".json")
.then(function(response) { return response.json(); })
.then(function(data) {
dictionary = data;
});
But I know IE doesn't support fetch. We've got jQuery available, so I tried:
jQuery.ajax({
url: "/libs/cq/i18n/dict." + lang + ".json",
success: function (response) {
dictionary = JSON.parse(response);
onReady();
}
})
Now I'm getting this:
SCRIPT1014: Invalid Character
index.js (49,17)
I realize the 49,17
is referring to a position in the file, line 49, char 17. That's the d in dictionary = JSON.parse(response);
I've tested the response, it's strict valid JSON.
For some reason dictionary = eval(response)
is working.