未捕获到的SyntaxError:意外的令牌},没有可见的错误? [英] Uncaught SyntaxError: Unexpected token }, no visible error?

查看:104
本文介绍了未捕获到的SyntaxError:意外的令牌},没有可见的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试运行Web应用程序的某些功能时(而其他功能似乎运行正常),我在index.php(行:30)上收到错误消息"Uncaught SyntaxError:Unexpected token}".

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).

我已经稍微缩小了范围.该错误似乎发生在"<?php"开头标记处(我发现这是因为在此标记后添加一行不会改变给出该错误的行,而是在该标记之前添加了一行,并且为该行给出了错误: 31).我已将代码放在记事本++中,以检查隐藏的字符,找不到任何不合适的东西. Dreamweaver没有语法错误...

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). 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...

我还查看了我的AJAX JS函数(位于单独的文件中).那里没有语法错误,也没有错位的字符.

I've also looked at my AJAX JS functions (which are in a separate file). No syntax errors there, no out of place characters either.

问题:谁能看到或解释造成此错误的原因?

QUESTION: Can anyone see or explain what is causing this error?

我将把代码放置在行:30"周围,将其视为错误所在.完整的代码在github上(放大后可以在此处发布所有代码):

I'll place the code surrounding "line: 30" where the error is meant to be. The full code is here on github (to large to post all code here):

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

代码:

    </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 -->
...........

推荐答案

在index.php中,您有以下几行:

In index.php, you have several lines like:

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>';

showURL的参数被双引号引起来,而对showURL本身的调用也是如此. showURL的参数需要有两个反斜杠.例如

The parameters to showURL are double-quoted, but so is the call to showURL itself. The parameters to showURL need to have a double backslash. E.g.

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

这篇关于未捕获到的SyntaxError:意外的令牌},没有可见的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆