passing array fields to jquery ajax
Posted
by
Rob Brandt
on Stack Overflow
See other posts from Stack Overflow
or by Rob Brandt
Published on 2012-10-19T04:54:31Z
Indexed on
2012/10/19
5:01 UTC
Read the original article
Hit count: 131
I have a form I am submitting via jquery ajax. Early in the form, I have this field:
<select name="inquirymodule[]" id="inquirymodule">
The user can add as many as they like, and all the selects go into the inquirymodule[] array.
The jQuery looks like this:
jQuery.ajax({
type: 'POST',
url: 'ajax.php',
dataType: 'json',
data: {
inquirymodule: jQuery("select[name='inquirymodule[]']").serialize(),
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert('error');
}
});
That works fine.
Trying to do the same thing with a date, like this:
<input class="formInput" type="text" id="startBreak0" name='startbreak[]' />
adding
startbreak: jQuery("select[name='startbreak[]']").serialize()
to the ajax call. It doesn't work, I cannot see why. Suggestions?
© Stack Overflow or respective owner