serialize()对于未选中的checkbox,radio是获取不到值的,在对应的js中自己修改下
$.fn.new_serialize = function () {
var a = this.serializeArray();
var $radio = $('input[type=radio],input[type=checkbox]', this);
var temp = {};
$.each($radio, function () {
if (!temp.hasOwnProperty(this.name)) {
if ($("input[name='" + this.name + "']:checked").length == 0) {
temp[this.name] = "";
a.push({name: this.name, value:0});
}
}
});
return jQuery.param(a);
};
然后调用$('form').new_serialize()