How to use getJson method properly

72 Views Asked by At

Here is my code I am getting error related "No 'Access-Control-Allow-Origin' header is present on the requested resource" how to use getJson method properly. Any help would be appreciated

  $.getJSON('//freegeoip.app/json/', function(location) {});

1

There are 1 best solutions below

0
Nilesh On

Try this :

 $.getJSON("//freegeoip.app/json/", function(result){
    $.each(result, function(i, field){
      $("div").append(field + " ");
    });
  });