![](/img/trans.png)
[英]Parse codebird reply into a array (or acces to the json text into the codebird's reply)
[英]JSON reply parse on JS
我需要解析来自服务器的回复,有一个代码:
$.getJSON('http://connect.mail.ru/share_count?callback=1&url_list=http://www.google.com&func=test', function(data) {
$('#ml_counter').text(data);
});
作为对http://connect.mail.ru/share_count?callback=1&url_list=http://www.google.com&func=test请求服务器的回复:
test(
{
"http://www.google.com":{"shares":574,"clicks":65}
});
我如何从中得到“574”?
callback: function(result) {
var yourVal = result['http://www.google.com'].shares;
}
在你的情况下:
.text(data['http://www.google.com'].shares);
请注意,将url作为参数返回并不是很舒服。 你最好只返回子对象或域对象列表(其中一个属性类似于url
而另一个属性是{ shares .... }
对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.