相关疑难解决方法(0)

未捕获的SyntaxError:意外的令牌:

我在我的MooTools脚本中运行一个AJAX调用,这在Firefox中工作正常但在Chrome中我收到Uncaught SyntaxError: Unexpected token :错误,我无法确定原因.注释掉代码来确定坏代码的位置什么都没有产生,我想这可能是返回JSON的问题.检查控制台我看到返回的JSON是这样的:

{"votes":47,"totalvotes":90}
Run Code Online (Sandbox Code Playgroud)

我没有看到任何问题,为什么会出现这种错误?

vote.each(function(e){
  e.set('send', {
    onRequest : function(){
      spinner.show();
    },
    onComplete : function(){
      spinner.hide();
    },
    onSuccess : function(resp){
      var j = JSON.decode(resp);
      if (!j) return false;
      var restaurant = e.getParent('.restaurant');
      restaurant.getElements('.votes')[0].set('html', j.votes + " vote(s)");
      $$('#restaurants .restaurant').pop().set('html', "Total Votes: " + j.totalvotes);
      buildRestaurantGraphs();
    }
  });

  e.addEvent('submit', function(e){
    e.stop();
    this.send();
  });
});
Run Code Online (Sandbox Code Playgroud)

javascript mootools google-chrome

178
推荐指数
7
解决办法
92万
查看次数

标签 统计

google-chrome ×1

javascript ×1

mootools ×1