jQuery序列化
Posted JohnRey
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jQuery序列化相关的知识,希望对你有一定的参考价值。
- html代码如下:
<form> 用户名:<input type="text" name="user"/> 邮件:<input type="text" name="email"/> <input type="radio" name="sex" value="男"/>男 <input type="radio" name="sex" value="女"/>女 <input type="button" value="提交"/> </form> <div id="box"></div>
- jQuery代码如下
$("form input[type=button]").click(function () { $.ajax({ type: "POST", url: "/user/", data:$("form").serialize(),//序列化form表单数据 success:function (response,status,xhr) { $("#box").html(response); } }); });
$("form input[name=sex]").click(function(){ $("#box").html(decodeURIComponent($(this).serialize()));//序列化radio数据,并对其解码 });
以上是关于jQuery序列化的主要内容,如果未能解决你的问题,请参考以下文章
markdown 在WordPress中使用jQuery代码片段