zoukankan      html  css  js  c++  java
  • Jquery的each遍历数据组成JSON

    遍历每个标签的值

      html代码:

        <volist name="parArr" id="item" key="$key">
                         <tbody>
                                 <tr>
                                       <td class="center number">{$key+1}</td>
                                        <td id='product_id' class="product_id">{$item.id}</td>
                                        <td>
                                              <a href="http://www.enkiorder.com/index.php/Home/detail/detail/id/{$item.id}" target="blank">{$item.name}</a>
                                         </td>

                 <td>
                                               <input type="hidden" value={$item.cid} class="cid">
                                               <input type="text" style="50px" value="{$item.heat}">
                                          </td>
                                       </tr>
                             </tbody>
                 </volist>

    JS代码:

      <script type="text/javascript">
                // console.log(json);
                $('#add').click(function(){
                    var json={};
                    $('.cid').each(function(){
                        var cid=$(this).val();
                        var heat=$(this).next().val();
                        console.log(heat);
                        json[cid]=heat;
                    })
                    $.ajax({
                        type:"POST",
                        data:json,
                        url:"{:U('Categorys/update')}",
                        success:function(msg){
                            if(msg!='no'){
                                alert('添加成功');
                                window.location.reload();
                            }
                        }
                    })
                })
            </script>

  • 相关阅读:
    embed 与 object
    通道
    Silverlight 插件中的FindName方法使用
    RenderTransformOrigin 的作用
    Photoshop工具与绘图
    Silverlight动画
    VS2005 数据连接提示:该项不适于在指定状态下使用
    IIS6注册.net4.0
    .NET中的动态编译
    DevExpress换肤
  • 原文地址:https://www.cnblogs.com/sweet521/p/5627930.html
Copyright © 2011-2022 走看看