What do you call this (interactive query strings)?

I finally decided to tackle AJAX and obtained my first working example from an online tutorial just the other day. I’m hooked!

But it’s going to be a steep learning curve, and I have a lot to learn about JavaScript.

One thing I find especially confusing is the way they string values together to make them interact with each other, like this:


 var age = document.getElementById('age').value;
 var wpm = document.getElementById('wpm').value;
 var sex = document.getElementById('sex').value;
 var queryString = "?age=" + age ;
 queryString +=  "&wpm=" + wpm + "&sex=" + sex;
 ajaxRequest.open("GET", "AjaxGender2.php" +
                              queryString, true);
 ajaxRequest.send(null);
}

This is part of a script that displays two boxes you can type numerical values into (Age and WPM), along with a button that lets you choose between the two genders.

So now I’m brainstorming various ways to use this - people who were born before or after a certain date, people who were born between two dates, animal families that have more than 50 species, animals that have been extinct for more than 50 million years, etc.

So I wondered if anyone could give me a head start by telling me if there’s a term for this - stringing values together so they interact with each other. I want to look for online tutorials but don’t know what term(s) to Google for.

Thanks.

Hi,

What the script is doing is concatenating strings and variables to build a query string which it then submits with the GET request (I think that’s the correct terminology).

If you are doing this for learning purposes, it might be worth looking at jQuery, as this abstracts away much of the ugly syntax, making it easier to focus on what the script is really doing.

http://api.jquery.com/jquery.ajax/

Thanks.