![](/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.