javascript - $.getJSON - unable to catch response when using parameters in url -


i have been struggling since yesterday following piece of code.

function findlocation(){    alert(1);    $.getjson( "http://www.omc4web.com/geoip/geoip.php",      {ip: "127.0.0.1",     callingurl: "www.thissite.com" },      function( result ){       alert(2);       $.each(result, function(i, field)       {         alert(i);          if(i=="country")         {            country_code = field;         }        });     })  } 

it not seem want beyond calling of php script. returned data {"country":"us","store":"us"} function not seem want process , never alert(2). have placed monitors in php script , can see indeed called correct parameters , return data expected.

if call http://www.omc4web.com/geoip/geoip.php?ip=127.0.0.1&callingurl=www.thissite.com browser see data returned.

the same piece of code calling url no parameters behaves correctly, not above setup.

my few remaining hairs appreciate on this.

additional info:

  • header('content-type: application/json'); set on php script

  • tried on chrome , firefox

  • no errors show on firebug blank response screen

  • running script localhost, if cross domain issue, why able make similar call (without params) amazon? $.getjson("http://freegeoip.net/json/",function(result){ works fine popular flickr example.

  • i using <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

thanks in advance

ossi

i think it's cross domain issue. guess you're able use freegeoip.net because you're using jsonp. try looking @ jquery documentation learn how use jsonp: jquery.getjson()


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -