jquery - Sending form data via $.post -
i have code here:
$.post('search_results.php', { name: form.name.value },
it helps me pass 1 value input field. have <select> </select>
, need pass too, need pass more variables.
how should it?
something like:
$.post('search_results.php', { name: form.name.value , select: form.select.value },
assuming elements in 1 form, easiest way use .serialize
:
$.post('search_results.php', $('#formid').serialize());
you can select form control elements want, example:
$('input[name="name"], select[name="gender"]').serialize()
Comments
Post a Comment