我如何获得geoplugin_continentCode
JSON.stringify的价值或获取数据的最佳方式是什么
$(document).ready(function() {
$.getJSON('//www.geoplugin.net/json.gp?jsoncallback=?', function(data) {
console.log(JSON.stringify(data, null, 2));
alert(JSON.stringify(data, null, 2))
// alert((JSON.stringify(geoplugin_continentCode));
//geoplugin_continentCode
});
$.getJSON('//ip-api.com/json?callback=?', function(data) {
//console.log(JSON.stringify(data, null, 2));
// alert(JSON.stringify(data, null, 2))
});
});
用这个 -
$(document).ready(function() {
$.getJSON('//www.geoplugin.net/json.gp?jsoncallback=?', function(data) {
console.log(data.geoplugin_continentCode);
});
});
解析为Json之后......
var dt = JSON.parse(data);
alert(data.geoplugin_continentCode);