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>

  • 相关阅读:
    浅谈SQL Server中的事务日志(五)----日志在高可用和灾难恢复中的作用
    浅谈SQL Server中的事务日志(四)----在完整恢复模式下日志的角色
    浅谈SQL Server中的事务日志(三)----在简单恢复模式下日志的角色
    Camera启动篇一
    【转】一篇不错的v4l2入门文档
    【转】open-drain与push-pull
    高通camera学习笔记五(actuator驱动参数解析)
    高通camera学习笔记四
    git精彩博文集锦
    【转】Git基础
  • 原文地址:https://www.cnblogs.com/sweet521/p/5627930.html
Copyright © 2011-2022 走看看