-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
  • 658
  • 2
  • 7
  • 23
Learning
  • 18,542
  • 37
  • 165
  • 337

2 Answers2

1

After parsing to Json ...

var dt = JSON.parse(data);
alert(data.geoplugin_continentCode);
1

Use this -

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