(070)jquery_异步_serialize

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
  <head>
    <title>ajax_serialize.html</title>
    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
    <style type="text/css">
        #divtest
        {
            width: 282px;
        }
        #divtest .title
        {
            padding: 8px;
            background-color:blue;
            color:#fff;
            height: 23px;
            line-height: 23px;
            font-size: 15px;
            font-weight: bold;
        }
        ul
        {
            float: left;
            width: 280px;
            padding: 5px 0px;
            margin: 0px;
            font-size: 14px;
            list-style-type: none;
        }
        ul li
        {
            float: left;
            width: 280px;
            height: 23px;
            line-height: 23px;
            padding: 3px 8px;
        }
        .fl
        {
            float: left;
        }
        .fr
        {
            float: right;
        }
    </style>
    <script type="text/javascript" src="../js/jquery/jquery190.js"></script>
    <script type="text/javascript">
        $(function(){
            $("#btnAction").bind("click",function(){
                $("#litest").html($("form").serialize());
            });
        });
    </script>
  </head>
  
  <body>
        <div id="divtest">
            <div class="title">
                <span class="fl">我的个人资料</span> 
                <span class="fr">
                    <input id="btnAction" type="button" value="序列化" />
                </span>
            </div>
            <form action="">
            <ul>
                <li>姓名:<input name="Text1" type="text" size="12" /></li>
                <li>
                    <select name="Select1">
                        <option value="0"></option>
                        <option value="1"></option>
                    </select>
                </li>
                <li><input name="Checkbox1" type="checkbox" />资料是否可见 </li>
                <li id="litest"></li>
            </ul>
            </form>
        </div>
  </body>
</html>

使用serialize()方法可以将表单中有name属性的元素值进行序列化,生成标准URL编码文本字符串,直接可用于ajax请求,它的调用格式如下:

$(selector).serialize()

posted @ 2015-01-05 09:19  雪中飞雁  阅读(64)  评论(0)    收藏  举报