Syntaxerror expected expression got

Как это исправить и с чем это связано?

В большинстве случаев это связано с тем, что в ответ на аякс запрос возвращается не то, что ожидается. Посмотри в консоли что приходит в ответ на данный запрос.

При клике по "Открыть/Закрыть" в консоли SyntaxError: expected expression, got end of script
registe. tIPoI=# (строка 1, столбец 10)

Но если этот код напрямую пихнуть в div то всё ок.
Код взял здесь vlvit.ru/jquery/raskrivayushiiesya-konteiener-div-.

  • Вопрос задан более трёх лет назад
  • 774 просмотра

В оригинале
А у вас

В результате у вас аттрибут onclick получился таким: onclick=’anichange(‘

А удалить кавычки вообще это конечно сильный ход, но я боюсь, что после этого отвалится return false

А правильный вариант выглядит примерно так:

Comments

Copy link Quote reply

motss commented Dec 12, 2016 •

Description

Have been dealing with the evil SyntaxError: expected expression, got ‘ on Firefox in the last couple of days and had totally no idea what had been gone wrong. Everything worked fine and great on Chrome 55, Opera 41, Safari 10 but not FF 50+.

***Update: This error SyntaxError: expected expression, got ‘ is most likely to happen when Service Workers is enabled and working fine on the browser. Since Service Worker in SPA will re-route basically anything that is not found to /index.html (according to default configuration) and so it does the same for .js . That’s why when app-indexeddb-mirror is looking for its .js files Service Worker couldn’t find it and just routed it to /index.html which then caused SyntaxError . In order to resolve that, we have to deliberately tell Service Worker to cache all the .js files within app-indexeddb-mirror like the following:

***Additional step for Firefox: Head over to about:debugging#workers in Firefox and unregister all service workers. Clear your offline storage in FF. Do a page refresh and boom. Everything works as expected without throwing SyntaxError anymore. Hope this will help those struggling with the evil SyntaxError. 😄

Expected outcome

app-indexeddb-mirror caches all JSONs from Firebase for offline use on all modern browsers.

Читайте также:  Mcafee consumer product removal

Actual outcome

FF50+ suffers from SyntaxError: expected expression, got ‘ .

Rate this post

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *