Reputation:
Sorry if my title is a little confusing I don't know really how to explain it.
API: http://mcping.net/api/162.223.8.210:25567
So I have this code that goes to an API, and I only want it to get the 'variables' online, and max. How would I do this?
Code:
$.get('http://mcping.net/api/162.223.8.210:25567', function(data){
$.each(data, function(index, item){
console.log(index + " ; " + item)
});
});
Upvotes: 1
Views: 53
Reputation: 31787
Try this
$.get('http://mcping.net/api/162.223.8.210:25567', function(data){
console.log(data.online);
console.log(data.max);
});
If your data
is already a Javascript object, so you can call its variables properties like in the snippet code.
Just in case I tested it in this fiddle http://jsfiddle.net/js18ykj1/
Upvotes: 3