-2

How can i get value of geoplugin_continentCode JSON.stringify or what is the best way to get data

$(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))
    });
});

Fiddle: http://jsfiddle.net/jrm2pk7q/1/

Lakshya Garg
  • 736
  • 2
  • 8
  • 23
Learning
  • 19,469
  • 39
  • 180
  • 373

2 Answers2

1

After parsing to Json ...

var dt = JSON.parse(data);
alert(data.geoplugin_continentCode);
Akbar Soft
  • 1,028
  • 10
  • 19
1

Use this -

$(document).ready(function() {
    $.getJSON('//www.geoplugin.net/json.gp?jsoncallback=?', function(data) {
      console.log(data.geoplugin_continentCode);
    });
});
Praveen Poonia
  • 745
  • 10
  • 18
  • It gives error in production Loading failed for the – Learning Sep 12 '18 at 11:28