比如我想读取的数据的网址是:https://api.douban.com/v2/book/1220562
里面的数据:{ “id”:“1220562”, “alt”:“https://book.douban.com/book/1220562”, “rating”:{“max”:10, “average”:“7.0”, “numRaters”:282, “min”:0}, “author”:[{“name”:“片山恭一”}, {“name”:“豫人”}], “alt_title”:"", “image”:“https://img3.doubanio.com/spic/s1747553.jpg”, “title”:“满月之夜白鲸现”}
我想要"average":“7.0” 这个7.0这个数据。
代码如下:
var fullUrl = “https://api.douban.com/v2/book/1220562”; xmlhttp=new XMLHttpRequest(); xmlhttp{ method: ‘GET’, url: fullUrl, headers: { ‘User-agent’: ‘Mozilla/4.0 (compatible) Greasemonkey’, ‘Accept’: ‘application/atom+xml,application/xml,text/xml’, }, onload: function(responseDetails) {
eval( responseDetails.responseText );
这里怎么写???
}
};
JSON.parse一下是不是更快