首页 > Web开发 > 详细

jQuery序列化

时间:2016-05-18 00:18:28      阅读:320      评论:0      收藏:0      [点我收藏+]
  • 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序列化

原文:http://www.cnblogs.com/Yellow0-0River/p/5503461.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!