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

troy beckett
12,035 PointsQuery Strings in AJAX
Just wondering if anyone could explain what determines the name and value pair when passing a query string in order retrieve data using an AJAX request?
2 Answers

miguelcastro2
Courses Plus Student 6,573 PointsWhen you make a request using AJAX you are simply making a request to a server URL. The URL is typically an application that is developed to provide some kind of response. What determines the key/values that a URL receives is determined by the application, which is ultimately determined by a developer.
If I wanted to make a web form that when I type in a zipcode it will return a US City and State, I could create a PHP script to do this. I know that I want to pass in a zipcode to get a city/state, so I will use zipcode as my parameter. The URL may look something like this:
http://www.myapp.com/myAJAXScript.php?zipcode=94101
The above script will return a JSON file that would contain my city and state information. The URL would be what I would call within my Javascript AJAX call.
So to wrap it up - it is the URL endpoint that determines what key/values you pass in.

troy beckett
12,035 PointsOK thanks.