[JS文件未在IE上加载,可在Joomla Seblod中的Chrome上使用

问题描述 投票:0回答:2

我在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上看到更改。

javascript internet-explorer joomla
2个回答
1
投票

parsererror:语法错误:期望的标识符

关于此错误,这意味着您在需要使用标识符的上下文中使用的不是标识符。标识符可以是:

  • 变量,
  • 属性,
  • 数组,
  • 或函数名称。

请检查您的JS脚本,并更改​​标识符表达式。

您也可以参考this threadthis question


0
投票

parsererror : SyntaxError: Expected identifier实际上是导致IE上的JS代码出现问题。我不得不进行逐行调试,最后在导致此的代码中找到了2个实例-

  1. 我用它来遍历对象for(const [serial, dates] of Object.entries(data)) {。必须用更简单的for ... in循环(例如[for (var serial in data){ if (data.hasOwnProperty(serial)) {

  2. )代替
  3. [我在脚本中使用sweetalert,并在其中使用.then((result) => {,通过一些挖掘,我发现IE不使用箭头运算符。因此,我使用了queue作为Sweetalert动作的替代方法,基本上执行了相同的步骤,但没有箭头运算符。

© www.soinside.com 2019 - 2024. All rights reserved.