(function($){
$.fn.serializeJson=function(){
if(this.tagName!='form') {
throw newDOMException('不是form标签!');
return;
}
varserializeObj={};
vararray=this.serializeArray();
varstr=this.serialize();
$(array).each(function(){
if(serializeObj[this.name]){
if($.isArray(serializeObj[this.name])){
serializeObj[this.name].push(this.value);
}else{
serializeObj[this.name]=[serializeObj[this.name],this.value];
}
}else{
serializeObj[this.name]=this.value;
}
});
returnserializeObj;
};
})(jQuery);
(function($){
$.fn.serializeOpJson=function(){
if(this.tagName!='form') {
throw newDOMException('不是form标签!');
return;
}
varserializeObj={};
$(this).find('.test-search').each(function(e,i) {
// console.log(i);
serializeObj[$(this).attr('name')] = $(this).data('op');
})
returnserializeObj;
};
})(jQuery);