我在MooTools脚本中运行一个AJAX调用,在Firefox中可以正常工作,但在Chrome中出现了Uncaught SyntaxError: Unexpected token :
错误,我无法确定原因。注释掉代码以确定坏代码所在的位置没有效果,我认为可能是返回的JSON有问题。在控制台中检查后发现返回的JSON如下:
{"votes":47,"totalvotes":90}
我没有看到任何问题,为什么会出现这个错误?
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();
});
});