- JSON: Uncaught SyntaxError: missing ) after argument list
- 2 Answers 2
- SyntaxError: missing ) after argument list
- 6 Answers 6
- How to reproduce this error:
- Ошибка: SyntaxError: missing ) after argument list
- JavaScript Error Handling: SyntaxError: missing ) after argument list
- The Technical Rundown
- When Should You Use It?
- Monitor Your App Free for 30 Days
- Как побороть ошибку SyntaxError: missing ) after argument list?
JSON: Uncaught SyntaxError: missing ) after argument list
In a rails app I have an object defined in a controller containing an icon and some values:
In view I parse it like this:
But I get the following error:
I works fine when I remove the icon code that contains the single quotes for class
How can I fix this error?
2 Answers 2
You want to send the HTML string to JS so need of to_json , as this is used to convert Hash to JSON . So just use html_safe in server side.
And in client side, since you have the all HTML in string no need of as_json , just use the string as you would normally do in JS. as_json is a method used as ActiveRecord Serializer.
Basically this seems to be an issue with an unescaped ‘ popping up somewhere in JSON.parse(‘. ‘) . You can verify the issue by looking at the HTML of the rendered page.
I think you might fix your issue by declaring (no need for the .to_json here):
And then in the view use
as you are only tring to pass a string there is no need for the conversion into a JSON object and then parsing it back. (You’d need that if you wanted to pass a whole Javescript Object/Ruby Hash).
Actually for the last line there is also an equivalent shortcut/alias:
PS: I described how to fix the imminent issue but generally the point of MVC is to not have (or at least to minimize) presentation logic in a conroller. Generally it would be preferable to pass the data to the view and generate the HTML in the template.
Источник
SyntaxError: missing ) after argument list
I am getting the syntax error:
From this jQuery code:
What kinds of mistakes produce this Javascript Syntax error?
6 Answers 6
You had a unescaped » in the onclick handler, escape it with \»
How to reproduce this error:
This code produces the error:
If you run this and look at the error output in firebug, you get this error. The empty function passed into ‘ready’ is not closed. Fix it like this:
And then the Javascript is interpreted correctly.
For me, once there was a mistake in spelling of function
For e.g. instead of
So keep that also in check
I faced the same issue in below scenario yesterday. However I fixed it as shown below. But it would be great if someone can explain me as to why this error was coming specifically in my case.
pasted content of index.ejs file that gave the error in the browser when I run my node file «app.js». It has a route «/blogs» that redirects to «index.ejs» file.
The error that came on the browser :
SyntaxError: missing ) after argument list in /home/ubuntu/workspace/RESTful/RESTfulBlogApp/views/index.ejs while compiling ejs
How I fixed it : I removed «=» in the include statements at the top and the bottom and it worked fine.
Источник
Ошибка: SyntaxError: missing ) after argument list
Не работает ни первый вариант со звездочкой, ни второй, тут явно дело не в звездочке.
Консоль выдает ошибку: SyntaxError: missing ) after argument list in
$(«img[src=»images/logo.jpg»]»).hide(3000);
jquery последней версии скачан.
Где я туплю? подскажите плиз
Uncaught SyntaxError: missing ) after argument list
Не могу понять, где я допускаю ошибку, помогите разобраться. Выбираем второго родителя и при.
Uncaught SyntaxError: missing ) after argument list
Здравствуйте! Консоль мне выводит ошибку адресс страницы: example.com/list/?hotel=Гранд Море В.
Ошибка: «Uncaught SyntaxError: missing ) after argument list»
Найти ошибку в коде script.js:3 Uncaught SyntaxError: missing ) after argument list.
SlideDown missing ) after argument list
Добрый вечер. Не могу заставить работать функцию: function SlideDown(id) < var elem =.
Uncaught SyntaxError: missing ) after argument list
var arr = str.match(https://vk.com/<><>/g);
Ошибка: «function call missing argument list»
При компиляции программы выскакивает сообщение об ошибке: 1.error C3867.
Источник
JavaScript Error Handling: SyntaxError: missing ) after argument list
Continuing through our JavaScript Error Handling series, today we’ll be looking closely at the Missing Parenthesis After Argument List JavaScript error. The Missing Parenthesis After Argument List error can occur for a variety of reasons, but like most SyntaxErrors , it commonly pops up when there’s a typo, an operator is missing, or a string is not escaped properly.
In this article we’ll examine the Missing Parenthesis After Argument List error in a bit more detail, including where it fits in the JavaScript Exception hierarchy, and what causes such errors to occur. Away we go!
The Technical Rundown
- All JavaScript error objects are descendants of the Error object, or an inherited object therein.
- The SyntaxError object is inherited from the Error object.
- The Missing Parenthesis After Argument List error is a specific type of SyntaxError object.
When Should You Use It?
As mentioned in the introduction, the Missing Parenthesis After Argument List error can occur for a variety of reasons. Most of the time, the issue relates to a typo or a forgotten operator of some kind. To better illustrate this, we can just explore a few simple examples.
A very typical action in JavaScript is to concatenate multiple strings together to form one larger string. This can be performed using a simple + operator between two strings: console.log(«Hello » + «world»);
Or, you can also concatenate strings inline, using backtick ( ` ) and bracket ( <> ) syntax: console.log(`Hello $
Regardless of how it’s done, many JavaScript methods accept an indefinite number of arguments (such as strings), including the console.log() method. In the example below, notice what happens if we forget to include any form of concatenation for our two strings:
The result is that we immediately produce a Missing Parenthesis After Argument List error:
As you may notice, we passed two arguments to console.log() , but we did not separate them by a typical comma ( , ), nor did we concatenate our two string values together with one of the above methods. This causes JavaScript to parse our code just fine, until it reaches the end of the first string ( is:» ) and moves onto the next argument ( name ). Since we didn’t tell it to concatenate, nor to expect another argument through the use of a comma separator, JavaScript expects that to be the end of our argument list to the console.log() method, and finds that our closing parenthesis is missing ( ) ), thus throwing a Missing Parenthesis After Argument List error.
The solution depends on how we want our code to behave, but in this case because we’re passing arguments to console.log() , we can achieve concatenation directly, or by simply adding a comma separator. The comma separator is generally more readable for our purposes, so let’s go with that option:
This gives us our name output as expected:
A rather simple fix, to be sure, but that’s the issue with the Missing Parenthesis After Argument List error, and with SyntaxErrors in general. They’re all so obvious once discovered, but unless your code editor parses and evaluates your code for syntax errors on the fly, it’s often easy to miss them until your test out the code yourself.
It’s also worth noting that, like other SyntaxErrors , the Missing Parenthesis After Argument List error cannot be easily captured by the typical try-catch block. Since the problem is syntax, the JavaScript engine’s attempt to execute the problematic code fails out at that exact moment. This usually means that it doesn’t reach the point in execution where it can continue to the catch portion of the block, since it doesn’t know how to parse that correctly. This can be worked around by displacing execution through different files and layers, but for all basic intents and purposes, catching SyntaxErrors is a major challenge.
To dive even deeper into understanding how your applications deal with JavaScript Errors, check out the revolutionary Airbrake JavaScript error tracking tool for real-time alerts and instantaneous insight into what went wrong with your JavaScript code.
Monitor Your App Free for 30 Days
Discover the power of Airbrake by starting a free 30-day trial of Airbrake. Quick sign-up, no credit card required. Get started.
Источник
Как побороть ошибку SyntaxError: missing ) after argument list?
Добрый день, помогите решить проблему)
Во фронте не силен, с горем пополам изначально настроил сборку для своего проекта, всё работало, сейчас решил пересобрать верстку и получаю ошибку:
Скрипты в package.json:
При npm run prod точно такая же ошибка, только путь соответственно до cross-env.
Не могу понять из-за чего это произошло, раньше все нормально работало.
Пробовал на линуксе и на Windwos 10, аналогичная ошибка.
Пробовал указывать полные пути node ./node_modules/webpack/bin/webpack.js вместо webpack , проблема не решилась(
- Вопрос задан 05 мар.
- 440 просмотров
Простой 16 комментариев
approximate solution, Kovalsky, я бы не стал сюда писать не облазив все страницы которые выдал мне гугл с этой ошибкой.
Я написал, что пробовал по разному указывать путь до webpack, однако, это никак не помогло и ошибка сохраняется.
Написал сюда, думая, что те кто с этим работает постоянно, знает какие-то тонкости, подводные камни и подскажет как сделать правильно, а не тупо кидать первые ссылки из гугла на стак или писать какой автор немощный, лучше никак чем так =)
hesy, Скидывайте код, причем весь, а не просто код с package.json. Желательно пушить всё на github в репо.
Никто не будет тратить своё время, что бы играть с вами в вангу, если вы сами не удосужились выкинуть код кроме как в текстовый редактор хабра.
approximate solution, может пароль от ftp и бд еще запушить и репу паблик сделать? =)
не видел, чтобы в аналогичных вопросах предоставляли ВЕСЬ код, но вопрос все же решался, увы не в моем случае конечно.
Никто не будет тратить своё время, что бы играть с вами в вангу
может пароль от ftp и бд еще запушить и репу паблик сделать? =)
А так хотелось украсть ваш код, мне до лучшей жизни не хватало конфига для вебпака, и пару долларов. Прошу прощение за беспокойство.
hesy, у меня там в конце после ссылки стоит вопросительный знак, который как раз остался там после сокращения фразы «а вот это вам не помогло?», то есть я рассчитывал что вы перейдёте по ссылке, попробуете решение предложенное там, потом скажете помогло ли; немощным я никого не называл,
Источник