简体   繁体   English

未捕获到的SyntaxError:意外令牌},没有可见错误?

[英]Uncaught SyntaxError: Unexpected token }, no visible error?

I am getting the error "Uncaught SyntaxError: Unexpected token }" on index.php (line: 30) when i try and run certain functions of my web app (while other functions seem to work fine). 当我尝试运行我的Web应用程序的某些功能时,而在index.php(行:30)上收到错误消息“ Uncaught SyntaxError:Unexpected token}”(而其他功能似乎运行正常)。

I've slightly narrowed down the problem. 我已经稍微缩小了范围。 The error seems to occur at the "<?php" opening tag (I found this because adding a line after this tag doesn't change the line the error is given for, but an extra line before the tag and the error is given for line: 31). 该错误似乎发生在"<?php"开始标签上(我发现这是因为在此标签后添加一行不会改变给出错误的行,但是在标签和错误之前给出了额外的一行行:31)。 I've put the code in note-pad++ to check for hidden characters, I couldn't find anything out of place. 我已将代码放在记事本++中,以检查隐藏的字符,找不到任何不合适的东西。 Dreamweaver gives no syntax errors... Dreamweaver没有给出语法错误...

I've also looked at my AJAX JS functions (which are in a separate file). 我还查看了我的AJAX JS函数(在单独的文件中)。 No syntax errors there, no out of place characters either. 那里没有语法错误,也没有错位字符。

QUESTION: Can anyone see or explain what is causing this error? 问题:谁能看到或解释造成此错误的原因?

I'll place the code surrounding "line: 30" where the error is meant to be. 我将把代码放置在“行:30”周围的错误所在。 The full code is here on github (to large to post all code here): 完整的代码在github上(放大后可以在此处发布所有代码):

https://github.com/bcdawber/URL-Vault-Web-Application https://github.com/bcdawber/URL-Vault-Web-Application

CODE: 码:

    </head>

    <body onLoad="showUrl('All URLs')">

    //console suggests error is somewhere here?
    <?php

        session_start();

        if(isset($_SESSION['userid'])) {

            echo '<div class="container">';
                echo '<div class="panel" id="backgroundPanel">';

                    echo '<div class="row">';
                        echo '<div class="large-12 columns">';
                            echo '<div class="panel">';
                                echo '<p><h2 id="title">URL VAULT</h2>';
                                echo '<h4 id="title">A Web Application for Storing URLs to Online Media.</h4></p>';
                            echo '</div>'; // <!-- END PANEL --> 
                        echo '</div>'; // <!-- END COLUMN (12) --> 
                    echo '</div>'; // <!-- END ROW -->
...........

In index.php, you have several lines like: 在index.php中,您可以看到几行内容:

echo '<a href="#" class="small button radius expand" onClick="showUrl("All URLs");return false;"/>All URLs</a>';
echo '<a href="#" class="small button radius expand" onClick="showUrl("Television");return false;"/>T.V URLs</a>';
echo '<a href="#" class="small button radius expand" onClick="showUrl("Movie");return false;"/>Movie URLs</a>';
echo '<a href="#" class="small button radius expand" onClick="showUrl("Music");return false;"/>Music URLs</a>';

The parameters to showURL are double-quoted, but so is the call to showURL itself. showURL的参数被双引号引起,而showURL本身的调用也被双引号引起来。 The parameters to showURL need to have a double backslash. showURL的参数需要有两个反斜杠。 Eg 例如

onClick="showUrl(\\"All URLs\\")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM