jquery easyui將form表單元素的值序列化成對象javascript
form表單java
<form id="ff"> <input type="text" id="username" name="username" value="zhangsan" data-options="required:true" /> </form>
直接提交序列化:jquery
$("#ff").serializeArray()
提交結果:函數
以下JS函數轉換提交序列化:ui
seachform = $("#ff").form(); serializeObject(seachform);
提交結果:this
轉換函數代碼:spa
function serializeObject(form){ var o={}; $.each(form.serializeArray(),function(index){ if(o[this['name'] ]){ o[this['name'] ] = o[this['name'] ] + "," + this['value']; }else{ o[this['name'] ]=this['value']; } }); return o; }
把easyui中的form表單中查詢條件的屬性序列成對象返回code