Hey everybody
I got a little problem. I want to use "FindNearbyPostalCodes" from geonames.org.
I have 2 textboxes (for lat & lng) and a submit button to submit the lat & lng to URL. I'm using AJAX. First I want to get the XML datas from geonames.org to my site. If this is successful, I do another AJAX post to display the XML data from geonames.org. So I got this code:
Code:
var lat = $('#lat').val();
var lng = $('#lng').val();
var test;
$.ajax({
url: "http://api.geonames.org/findNearbyPostalCodes",
type: "GET",
data: {lat: lat, lng: lng, radius: 20, maxRows: 100, country: "CH", username: "bbag8274"},
success: function(scriptData, textStatus, jqXHR){
// second
alert($.parseXML( test ));
$.ajax({
url: "test_data.php",
type: "POST",
data: {xmldata: test},
contentType: "text/xml",
success: function(secondScriptData, textStatus, jqXHR){
alert(secondScriptData);
},
error: function(jqXHR, textStatus, errorThrown){
alert('Unknown error, report it!');
}
});
// end second
},
error: function(jqXHR, textStatus, errorThrown){
alert('fail');
}
});
The variable "test" I created so I can look what it alerts me. And thats the point. It always returns me "null". I don't know if there is a programming mistake or where it is or if it is something with the WebService connection? I can't figure it out.
Hope someone could help
Thanks