zoukankan      html  css  js  c++  java
  • 如何循环html数据制作[{},{}]格式,向后台传递多个数据

    var allobject=[ ];
    $('.P_center').each(function(){
                    //获取对象所需要的值
                    var courseId = $(this).data('id');
                    var buyNum = $(this).data('quantity');
                    var buyPrice = $('.P_su').text();

                   //将获取好的值保存到对象中
                    var object = {
                        "courseId":courseId,
                        "buyNum":buyNum,
                        "buyPrice":buyPrice
                    }
                   //将对象保存到数组中
                    
                    allobject.push(object );
                });
               //将数组转换为json类型的字符串
               var allobjectJSON = JSON.stringify(allobject);
  • 相关阅读:
    将博客搬至CSDN
    defender 月考总结
    生日祝福@陈俊翰
    个性签名
    你这是virus吧?
    (CPSCA's)CPOJC+VIJOS
    Sentence by defender
    工作制一览
    最长上升子序列
    mysql约束
  • 原文地址:https://www.cnblogs.com/wjhaaa/p/9042382.html
Copyright © 2011-2022 走看看