var form = $("<form></form>");
form.append($("<input type='hidden' name='name' value='张' />"));
form.append($("<input type='hidden' name='deptId[0]' value='1001' />"));
form.append($("<input type='hidden' name='deptId[1]' value='1002' />"));
var formStr = $(form).serialize();
console.log(formStr);
console.log(decodeURI(formStr));
输出:
name=%E5%BC%A0&deptId%5B0%5D=1001&deptId%5B1%5D=1002
name=张&deptId[0]=1001&deptId[1]=1002