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>

  • 相关阅读:
    尽解powershell的workflow
    powershell玩转iis网站服务器
    Windows Terminal (Preview)治好了cmd,powershell的癌症
    博客园“NET Core 版博客系统”的运维浅见
    此贴告诉你:为啥shell脚本人,不建议学python
    关于revit的外部扩展存储
    Revit二次开发 屏蔽复制构件产生的重复类型提示窗
    xpath测试工具 xpath调试工具
    c# 防止重复运行 弹出已运行窗口并传递消息
    .NET APlayer播放器 demo
  • 原文地址:https://www.cnblogs.com/sweet521/p/5627930.html
Copyright © 2011-2022 走看看