Javascript 获取backbone.js时Json中出现语法错误

Javascript 获取backbone.js时Json中出现语法错误,javascript,json,backbone.js,Javascript,Json,Backbone.js,我正在尝试从JSON获取数据,并尝试显示它。获取json时,它在获取中抛出错误。我被困在这一点上太多天了,从谷歌阅读后,我感到困惑。有人能帮我找出错误是什么以及如何继续吗 <!DOCTYPE html> <html> <head> <title>Fortified Studio</title> </head> <body>test <div id="profiles"><

我正在尝试从JSON获取数据,并尝试显示它。获取json时,它在获取中抛出错误。我被困在这一点上太多天了,从谷歌阅读后,我感到困惑。有人能帮我找出错误是什么以及如何继续吗

<!DOCTYPE html>
<html>
     <head>
  <title>Fortified Studio</title>
 </head>
 <body>test

  <div id="profiles"></div>

        <script id="profileTemplate" type="text/template">
            <div class="profile">
                <div class="info">
                    <div class="name">
                        <%= name %>
                    </div>

                </div>
            </div>
        </script>
  </body>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>   
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script>
    <script>
    $(function() {
        console.log("start of script");
    var Prof = Backbone.Model.extend({});
    var ProfList= Backbone.Collection.extend ({
    model: Prof,
    url : '/data/testjson2.json'

    }); 
    var ProfView = Backbone.View.extend ({

        initialize: function (){
            console.log("View initialize");
            this.render();
        },
        render : function (){
            console.log("in render");
            template: _.template($('#profileTemplate').html()),
            _.each (this.collection, function(Prof) {
                var profileTemplate = this.template(Prof.toJSON());
                $(this.el).append(profileTemplate);
            }, this);
            console.log (this);
            return this;
        }


    });


 var profs = new ProfList ();
 var profViews = new ProfView ();
  new ProfList().fetch({
      sucess : function(){
          console.log('json loaded');
      },
      error: function (){
            console.log("error retrieving model");
      }

  });

     profViews.render();
  }); 




    </script>

</html>
控制台上的输出为:-

.......
Unknown property 'box-sizing'.  Declaration dropped.               myFile.html
"start of script"                                                 myFile.html:27
"View initialize"                                                 myFile.html:37
"in render"                                                       myFile.html:41
[object Object]                                                   myFile.html:47
"in render"                                                       myFile.html:41
[object Object]                                                   myFile.html:47
 GET /data/testjson2.json        [HTTP/1.1 200 OK 3ms]
syntax error                                                      testjson2.json:1
 "error retrieving model"                                          myFile.html:62

请帮助我,如何继续。

删除每个值集末尾的逗号

<!DOCTYPE html>
<html>
     <head>
  <title>Fortified Studio</title>
 </head>
 <body>test

  <div id="profiles"></div>

        <script id="profileTemplate" type="text/template">
            <div class="profile">
                <div class="info">
                    <div class="name">
                        <%= name %>
                    </div>

                </div>
            </div>
        </script>
  </body>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>   
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script>
    <script>
    $(function() {
        console.log("start of script");
    var Prof = Backbone.Model.extend({});
    var ProfList= Backbone.Collection.extend ({
    model: Prof,
    url : '/data/testjson2.json'

    }); 
    var ProfView = Backbone.View.extend ({

        initialize: function (){
            console.log("View initialize");
            this.render();
        },
        render : function (){
            console.log("in render");
            template: _.template($('#profileTemplate').html()),
            _.each (this.collection, function(Prof) {
                var profileTemplate = this.template(Prof.toJSON());
                $(this.el).append(profileTemplate);
            }, this);
            console.log (this);
            return this;
        }


    });


 var profs = new ProfList ();
 var profViews = new ProfView ();
  new ProfList().fetch({
      sucess : function(){
          console.log('json loaded');
      },
      error: function (){
            console.log("error retrieving model");
      }

  });

     profViews.render();
  }); 




    </script>

</html>
[
  {
    "name":"Johny Johny"
  },
  {
    "name":"Jack n Jill"
  }
]
使用以下方法测试JSON:

控制台日志与您描述的问题无关。它实际上抛出了什么错误?哦,等等,有几条留言。固定格式。您的JSON是有效的。很可能服务器也在发送其他东西?@Jan dvorak:实际上,我的动机是从json获取数据并显示。当获取而不是抛出success时,它抛出的是error msg。此外,我不知道如何在前端打印它。我的第二个疑问是“为什么[object,object]要打印,因为它应该打印frm json的值?”