Why does this semicolon appear if I use jQuery serialize() on inputs with square brackets in the name? Why does this semicolon appear if I use jQuery serialize() on inputs with square brackets in the name? ajax ajax

Why does this semicolon appear if I use jQuery serialize() on inputs with square brackets in the name?


I had this exact problem, and I was only able to get it to work by using ".serializeArray()", I hope this was what you were looking for.

data: {    'options':$('input[name="options[]"]').serializeArray()},

For me this outputs standard string in the same format as GET requests.


I recommend to remove [] from html names, it's bad design. There can be a problem on jQuery side or PHP too.I can see no other problems in your code.

What characters are allowed in the HTML Name attribute?
What are valid values for the id attribute in HTML?


Why do you use the brackets[] and the same name for each input element?If I get you right you can serialize by a wrapping element..

<form id="options">    <input type="checkbox" id="options_1" value="options_1" name="option1" />      <input type="checkbox" id="options_2" value="options_2" name="option2" />      <input type="checkbox" id="options_3" value="options_3" name="option3" />  </form>

So you can serialize like

data: {    'options':$('#options').serialize()},