I need to parse reply from server, have a code:
$.getJSON('http://connect.mail.ru/share_count?callback=1&url_list=http://www.google.com&func=test', function(data) {
$('#ml_counter').text(data);
});
as a reply on http://connect.mail.ru/share_count?callback=1&url_list=http://www.google.com&func=test request server gives:
test(
{
"http://www.google.com":{"shares":574,"clicks":65}
});
How can I get "574" from this?
callback: function(result) {
var yourVal = result['http://www.google.com'].shares;
}
In your situation:
.text(data['http://www.google.com'].shares);
Note that returning the url as a parameter isn't really comforting. You're way better of returning just the child object or a list of domain-objects (where one of the properties is something like url
and another is the { shares .... }
object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.