SyntaxError: missing ) after argument list

后端 未结 6 833
滥情空心
滥情空心 2020-12-05 13:54

I am getting the syntax error:

SyntaxError: missing ) after argument list

From this jQuery code:

$(\'#contentData\').append         


        
相关标签:
6条回答
  • 2020-12-05 14:03

    use:

    my_function({width:12});
    

    Instead of:

    my_function(width:12);
    
    0 讨论(0)
  • 2020-12-05 14:04

    You had a unescaped " in the onclick handler, escape it with \"

    $('#contentData').append("<div class='media'><div class='media-body'><h4 class='media-heading'>" + v.Name + "</h4><p>" + v.Description + "</p><a class='btn' href='" + type + "'  onclick=\"(canLaunch('" + v.LibraryItemId + " '))\">View &raquo;</a></div></div>")
    
    0 讨论(0)
  • 2020-12-05 14:09

    For me, once there was a mistake in spelling of function

    For e.g. instead of

    $(document).ready(function(){
    
    });
    

    I wrote

    $(document).ready(funciton(){
    
    });
    

    So keep that also in check

    0 讨论(0)
  • 2020-12-05 14:13

    SyntaxError: missing ) after argument list.

    the issue also may occur if you pass string directly without a single or double quote.

    $('#contentData').append("<div class='media'><div class='media-body'><a class='btn' href='" + type + "'  onclick=\"(canLaunch(' + v.LibraryItemName +  '))\">View &raquo;</a></div></div>").
    

    so always keep the habit to pass in a quote like

     onclick=\"(canLaunch(\'' + v.LibraryItemName  + '\'))"\
    
    0 讨论(0)
  • 2020-12-05 14:22

    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.

    <%= include partials/header %>
    <h1>Index Page</h1>
    <% blogs.forEach(function(blog){ %>
        <div>
            <h2><%= blog.title %></h2>
            <image src="<%= blog.image %>">
            <span><%= blog.created %></span>
            <p><%= blog.body %></p>
        </div>
    <% }) %>
    <%= include partials/footer %>
    

    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.

    0 讨论(0)
  • 2020-12-05 14:28

    How to reproduce this error:

    SyntaxError: missing ) after argument list
    

    This code produces the error:

    <html>
    <body>
    <script type="text/javascript" src="jquery-2.1.0.min.js"></script>
    <script type="text/javascript">
      $(document).ready(function(){
    
      }
    </script>
    </body>
    </html>
    

    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:

    <html>
    <body>
    <script type="text/javascript" src="jquery-2.1.0.min.js"></script>
    <script type="text/javascript">
      $(document).ready(function(){
    
      });      //<-- notice the right parenthesis and semicolon
    </script>
    </body>
    </html>
    

    And then the Javascript is interpreted correctly.

    0 讨论(0)
提交回复
热议问题