您好我正在学习如何使用protovis,到目前为止这么好,但现在我偶然发现了一个我似乎无法解决的问题。语法:Error JSON.parse,试图加载原始数据
以下是代码。 (我有最新的jQuery在我的头加载)
<script type="text/javascript+protovis">
var dataURL = "http://eagereyes.org/media/2010/protovis-primer/earthquakes.json";
var JSONdata = $.ajax({ type: "GET", url: dataURL, async: false }).responseText;
var earthquakes = JSON.parse(JSONdata);
var width = 560;
var height = 245;
var barWidth = width/earthquakes.length;
var gap = 2;
new pv.Panel().width(width).height(height+5)
.add(pv.Bar)
.data(earthquakes)
.bottom(0)
.width(barWidth-gap)
.height(function(d) d.Magnitude * (height/9))
.left(function() this.index * barWidth)
.root.render();
当我尝试这样在Firefox中我得到这个警告:
Syntax:Error JSON.parse
我已经验证了JSON上http://www.jsonlint.com/已经。所以问题必须在别处。
任何人都知道这是怎么回事?
编辑
我试图在protoviewer应用程序加载相同的数据:http://www.rioleo.org/protoviewer/和它的作品。所以它一定是代码。
谢谢!我使用的是Firefox(Latest),我也在Safari中检查过。警报(JSON)给了我:[对象JSON] – bottleboot 2011-01-14 21:29:44
好的,再次感谢。第一个警报(JSON数据)给了我一个空警报,然后是错误。第二个只有错误。 – bottleboot 2011-01-14 21:46:43