簡體   English   中英

JS 文件未在 IE 上加載,可在 Joomla Seblod 中的 Chrome 上運行

[英]JS file not loading on IE, works on Chrome in Joomla Seblod

我在 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 上的變化。

解析器錯誤:語法錯誤:預期的標識符

至於這個錯誤,這意味着您在需要標識符的上下文中使用了標識符以外的東西。 標識符可以是:

  • 一個變量,
  • 一個財產,
  • 數組,
  • 或 function 名稱。

請檢查您的 JS 腳本,並更改標識符表達式。

你也可以參考這個線程這個問題

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. 我在我的腳本中使用了 sweetalert和一個 .then .then((result) => {在里面,在一些挖掘中我發現 IE 不使用箭頭操作符。所以我使用了一個關於 sweetalert 動作的queue和基本上做了相同的步驟,但沒有箭頭操作符。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM