ajax提交表单数据

浏览:2945 发布日期:2017/04/16 分类:求助交流 关键字: ajax checkbox
<html>
<head>
<title>复选框列表</title>
<script type="text/javascript" src="__PUBLIC__/Admin/Js/jquery-1.4.min.js"></script>
</head>

<body>
<form action="{:U('Search/listCondition')}" method="POST">
    <input id="hid" type="hidden" name="name" value="{$name}">
    <foreach name='fields' item="vo">
        <input type="checkbox" name="{$vo.Comment}" value="{$vo.Field}">{$vo.Comment}  
    </foreach>
    <input type="submit" value="展示可搜索字段">
    <input id="btn2" type="button" value="button提交">
</form>
<div id="list"></div>
</body>
</html>

<script>

    var pdata = $("input[name='{$vo.Comment}']:checked").serialize();
        $(document).ready(function(){
              $("#btn2").click(function(){
                  $.ajax({
                    url:'{:U('Search/listCondition')}',
                      type:"POST",
                      data:{
                        name:$("#hid").val(),
                        $pdata,
                    },
                      success:function(ret){
                        $("#list").empty(ret);
                        // 追加进id=test的div中去
                        $("#list").append(ret);
                      

                      }
                  });
            });
        });
    </script>
网友们,这个data数据这里要怎么写呀!
最佳答案
评论( 相关
后面还有条评论,点击查看>>