成都网站建设设计

将想法与焦点和您一起共享

解决layui批量传值到后台操作时出现传值为空的问题

解决layui批量传值到后台操作时出现传值为空的问题

创新互联建站专注于巴马企业网站建设,成都响应式网站建设公司,成都商城网站开发。巴马网站建设公司,为巴马等地区提供建站服务。全流程定制网站,专业设计,全程项目跟踪,创新互联建站专业和态度为您提供的服务

 如图,前台的样子,data的参数为

[

{"good_id":1,"good_name":"标样-总磷","good_num":"BY400014","pid":10,"first_pid":1,"good_standard":"1.46mg/L","good_cas":"7220-81-7","good_spe":"1mL","normal_price":"500.00","good_stock":"322","good_indate":"1600876800","cash_sale":"1","good_url":"/uploads/20190923/eaa8577dd76344a3ed15cc3ca0146a50.jpg","company":"TMstandard","good_sort":99,"good_new":1,"good_promotion":1,"create_time":"1569222082"}

,{"good_id":2,"good_name":"水中甲醛(HJ601-2011水质甲醛的测定乙酰","good_num":"BW20040-100-W-20","pid":14,"first_pid":2,"good_standard":"100mg/L","good_cas":"50-00-0","good_spe":"20mL","normal_price":"90.00","good_stock":"280","good_indate":"1630512000","cash_sale":"1","good_url":"/uploads/20190923/8ca481784cc15ee27399e754d788aad1.jpg","company":"坛墨质检","good_sort":99,"good_new":1,"good_promotion":1,"create_time":"1569222248"}

]

大概就是要批量删除两条记录,然后死活无法传值到后台,传过去返回一看就是undefined,卡了一上午!!!!

最后解决,之后就能获取到传的值了{"id":["1","2"]},当然这里使用json_encode尽心json处理了

var data = checkStatus.data;
     var id = new Array();//这里还有个小插曲,创建空数组时,必须使用Array、array就会报错,笑哭了,底子不牢固啊
     console.log(JSON.stringify(data));
     for(var i in data){
      id[i] = data[i].good_id;
     }
     $.ajax({
      url:'',//后台控制器
      type:'post',
      data:{
       'id':id
      },
      dataType:'json',
      success:function (msg) {
       console.log(msg);
      }
     }); 

以上这篇解决layui批量传值到后台操作时出现传值为空的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持创新互联。


文章标题:解决layui批量传值到后台操作时出现传值为空的问题
文章来源:http://chengdu.cdxwcx.cn/article/pjsgpj.html