[jQuery] generate AJAX data based on number of select elements
Okay, so I've been working with the Facebook Like autosuggest thing:
http://web2ajax.fr/2008/02/03/facebook-like-jquery-and-autosuggest-search-engine/
I've adapted it to my system to make a request system for whatever
literature people want. They select something from the results, and a
div (within a form) gets populated with a li and a select box with the
quantity they want of that piece of literature.
So I want to send this request to the server via AJAX/AHAH/AJAH
whatever, but I don't know how to dynamically include the SELECT
element's values into the data part of the $.ajax... I thought if
maybe I did a var for the different data fields, I could just pass
that one var to the $.ajax data option, but again, I'm stuck trying to
figure out how I can loop through the select elements with classname
of "litqty" and add them to the data var to pass to the $.ajax
function
$(function() {
var reqData = {
$('.litqty').each(
//do something here to add it like this:
unique-id-or-name-of-select: value-of-select
);
}
$("form#form_search_country").submit(function() {
$.ajax('submitLitRequest.php', {
data: reqData
}
);
});
I hope that makes sense. Thanks in advance for any help !