0

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.

manishk
  • 526
  • 8
  • 26

2 Answers2

1

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.

Zhi Lv
  • 18,845
  • 1
  • 19
  • 30
  • It was exactly this issue causing the problem. The links helped a lot. It took me through a debugging hell as it wasn't specified anywhere what exactly was causing it. Thanks for pointing this out. – manishk Oct 31 '19 at 16:14
0

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.

manishk
  • 526
  • 8
  • 26