Hi!
I am requesting a webservice to pull lat/lng coordinates by using country names from a php file using this code:
$defaultcountry = $_REQUEST['country'];
$daurl = "http://ws.geonames.org/search?q=".$defaultcountry.'&rows=5';
$contents = file_get_contents($daurl);
$xml = new SimpleXMLElement($contents);
$lat = $xml->geoname->lat;
$lng = $xml->geoname->lng;
$coords = array('lat'=>"$lat", 'lng'=>"$lng");
$o = array('success'=>true, 'coords'=>$coords);
echo json_encode($o);
i dont have issues calling this file directly from the browser. The problem is when this file is being called by ajax somewhere, like so:
ajaxManager.add('cacheQueue',{
url: '../lib/getdefaultcoord.php',
type:'POST',
dataType:'json',
data:{country:Country},
success:function(json){
alert(json.coords.lng);
}
})
thus, error comes up as stated on my subject line. I have a similar scenario for requesting countrynames using a different webservice url (webservicex.net). That one from geonames.com does not seem to work when requests are made via ajax... How come?