我在Joomla Seblod上添加了JS作为字段,它在我的文件系统my_profile.js中按如下方式调用JS文件-
jQuery.getScript("/components/com_msp/js/my_profile.js")
.done(function(script, textStatus) {
console.log('inside success in seblod');
main();
}).fail(function( jqxhr, settings, exception ) {
console.log('JS failed in seblod..');
console.log(JSON.stringify(jqxhr));
console.log( "Error:" + settings + ' : ' + exception );
});
在Chrome上,正确调用了JS,并且所有代码都可以正常工作(在Inspect控制台上,我也收到inside success in seblod
消息),但是在IE上,我在控制台上得到了此代码-
The code on this page disabled back and forward caching.
JS failed in seblod..
Error:parsererror : SyntaxError: Expected identifier
文件内的代码和所有内容都相同。直到昨天,我也可以在IE上看到更改。
parsererror:语法错误:期望的标识符
关于此错误,这意味着您在需要使用标识符的上下文中使用的不是标识符。标识符可以是:
请检查您的JS脚本,并更改标识符表达式。
您也可以参考this thread和this question。
parsererror : SyntaxError: Expected identifier
实际上是导致IE上的JS代码出现问题。我不得不进行逐行调试,最后在导致此的代码中找到了2个实例-
我用它来遍历对象for(const [serial, dates] of Object.entries(data)) {
。必须用更简单的for ... in循环(例如[for (var serial in data){ if (data.hasOwnProperty(serial)) {
[我在脚本中使用sweetalert,并在其中使用.then((result) => {
,通过一些挖掘,我发现IE不使用箭头运算符。因此,我使用了queue
作为Sweetalert动作的替代方法,基本上执行了相同的步骤,但没有箭头运算符。