Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AJAX Basics (retiring) jQuery and AJAX Posting Data with jQuery

passing variable and getting the result.

I was wondering how can i use postal code text field and get result based on filled in postal code, from another server, while i display the result in a div. The reason i ask for a postal code, is i have a long form but just want to use postal code or house no, text field on finding correct address via that?

Tommy May
Tommy May
12,056 Points

Hi Ammar if I understand your question you want to use a form to capture a users zip code. Then use that captured postal code to automatically display the city and state?

If this is your question I would suggest looking into reverse geocoding. You will need to use an api to accomplish what you want easily. Google has an api you can use with examples on how to use it. https://developers.google.com/maps/documentation/javascript/examples/geocoding-reverse

Hope this helps.

Tommy May I will look into it, one of reason to my post is to find out, on how to send whole or selected form data as we do for normal ones like fname = $_POST['firstname'] etc. The course or video didn't cover that, as i think serialize() is something but it won't do much good.