manishk
manishk

Reputation: 536

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

I have added JS as a field on Joomla Seblod, which calls a JS file in my file system my_profile.js as follows-

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 );
});

On Chrome, the JS is called correctly and all the code works (I also get inside success in seblod message on the Inspect console), but on IE I get this on the console-

The code on this page disabled back and forward caching.
JS failed in seblod..
Error:parsererror : SyntaxError: Expected identifier

The code inside the files and everything is the same. Till yesterday I could see the changes on IE as well.

Upvotes: 0

Views: 66

Answers (2)

manishk
manishk

Reputation: 536

parsererror : SyntaxError: Expected identifier was actually causing issues with the JS code on IE. I had to do a line by line debug and finally found 2 instances in the code that was causing this-

  1. I was using this to loop through an object- for(const [serial, dates] of Object.entries(data)) {. Had to replace this with a simpler for...in loop like- for (var serial in data){ if (data.hasOwnProperty(serial)) {

  2. I'm using sweetalert in my script and a .then((result) => { inside it, and on some digging I found that IE doesn't take the arrow operators. So instead of that I used a queue on sweetalert actions and basically did the same steps but without the arrow operator.

Upvotes: 0

Zhi Lv
Zhi Lv

Reputation: 21561

parsererror : SyntaxError: Expected identifier

As for this error, it means you are using something other than an identifier in a context where one was required. An identifier can be:

  • a variable,
  • a property,
  • an array,
  • or a function name.

Please check your JS script, and change the identifier expression.

You could also refer to this thread and this question.

Upvotes: 1

Related Questions