jquery自定义转换json插件
<body><form action="#" method="post" id="form1">
<input type="text" name="username" value="zhangxueliang"/>
<input type="text" name="password" value="123456"/>
</form>
</body>
<script src="js/jquery-1.8.3.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$.fn.extend({
serializeJson:function(){
var json={};
var msg = this.serializeArray();
$(msg).each(function(){
json=this.value;
});
return json;
}
});
$(function(){
var formData = $("#form1").serializeJson();
alert(formData);
})
</script>
文档来源:51CTO技术博客https://blog.51cto.com/u_7692005/3061933
页:
[1]