Below is my $.ajax call, how do I put a selects (multiple) selected values in the data section?
$.ajax({ type: 'post', url: 'http://myServer' , dataType: 'text', data: { 'service' : 'myService', 'program' : 'myProgram', 'start' : start, 'end' : end , }, success: function(request) { result.innerHTML = request ; } // End success }); // End ajax method
EDIT I should have included that I understand how to loop through the selects selected options with this code:
$('#userid option').each(function(i) { if (this.selected == true) {
but how do I fit that into my data: section?
how about using an array?
edit: ah sorry, here’s the code, a few caveats:
in order for serializeArray() to work though, all form elements must have a name attribute. the value of
'select'above will be an array of objects containing the name and values of the selected elements.the select box to produce the above result would be: