ajax - jquery serialize multiple checkboxes with same name -


i have searched , searched cannot find answer fit exact situation. hoping can help.

i trying "retrofit" site using frames use ajax , divs now. going well, except...

this site has multiple forms. trying write jquery code handle forms (using ajax of course). therefore, using id selectors , out. real problem comes in when using serialize() handle multiple checkboxes same name.

consider following scenario:

html

<form name="theform" method="post" action="form.cgi"> <input type="hidden" name="directory" value="test"> <input type="checkbox" name="file" value="file1.txt"> <input type="checkbox" name="file" value="file2.txt"> ... <input type="checkbox" name="file" value="file10.txt"> <input type="submit" name="submit" value="submit"> </form> 

jquery

$(':submit').click(function(e){ e.preventdefault(); //serialize form data parent form of clicked submit button //this enable handling of forms across site var formdata=$(this.form).serialize(); $.ajax({type: "post", url: "form.cgi", data: formdata, cache: false,  contenttype: false, processdata: false, success:function({alert(formdata);}}); }); 

this results in alert showing directory field , corresponding value. none of checkboxes (checked checkboxes, is) showing in data string.

why serialize() not handling checkboxes? have read cases of cycling through checkboxes, not sure if possible. keep in mind processing script uses data in format of name=value data fed in should file=file1.txt&file=file2.txt&file=file3.txt.

hope can me this...this one's got me befuddled.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -