<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "Connect to WebService with AJAX post"]]></title>
		<link>http://forum.geonames.org/gforum/posts/list/7.page</link>
		<description><![CDATA[Latest messages posted in the topic "Connect to WebService with AJAX post"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Connect to WebService with AJAX post</title>
				<description><![CDATA[ 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:

<span class="genmed"><b>Code:</b></span><br>
		<div style="overflow: auto; width: 100%;">
		<pre>
var lat = $&#40;'#lat'&#41;.val&#40;&#41;;
var lng = $&#40;'#lng'&#41;.val&#40;&#41;;
var test;
$.ajax&#40;{
	url: "http://api.geonames.org/findNearbyPostalCodes",
	type: "GET",
	data: {lat: lat, lng: lng, radius: 20, maxRows: 100, country: "CH", username: "bbag8274"},
	success: function&#40;scriptData, textStatus, jqXHR&#41;{

	        // second
			
	        alert&#40;$.parseXML&#40; test &#41;&#41;;
	        $.ajax&#40;{
		        url: "test_data.php",
		        type: "POST",
		        data: {xmldata: test},
		        contentType: "text/xml",
		        success: function&#40;secondScriptData, textStatus, jqXHR&#41;{
			        alert&#40;secondScriptData&#41;;
		        },
					
		        error: function&#40;jqXHR, textStatus, errorThrown&#41;{
			        alert&#40;'Unknown error, report it!'&#41;;
		        }
	        }&#41;;
				
	        // end second
				
	},
	error: function&#40;jqXHR, textStatus, errorThrown&#41;{
		alert&#40;'fail'&#41;;
	}
}&#41;;
</pre>
		</div>

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]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/list/4831.page#13262</guid>
				<link>http://forum.geonames.org/gforum/posts/list/4831.page#13262</link>
				<pubDate><![CDATA[Thu, 19 Dec 2013 20:48:54]]> GMT</pubDate>
				<author><![CDATA[ bbag8274]]></author>
			</item>
	</channel>
</rss>