Jquery的each遍历数据组成JSON

遍历每个标签的值

  html代码:

    <volist name="parArr" >{$item.name}</a>

</td>

             <td>

<input type="hidden" value={$item.cid} class="cid">

<input type="text" 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>