溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

解決layui批量傳值到后臺(tái)操作時(shí)出現(xiàn)傳值為空的問(wèn)題

發(fā)布時(shí)間:2020-09-29 13:26:19 來(lái)源:腳本之家 閱讀:244 作者:大尹 欄目:web開發(fā)

解決layui批量傳值到后臺(tái)操作時(shí)出現(xiàn)傳值為空的問(wèn)題

 如圖,前臺(tái)的樣子,data的參數(shù)為

[

{"good_id":1,"good_name":"標(biāo)樣-總磷","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水質(zhì)甲醛的測(cè)定乙酰","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":"壇墨質(zhì)檢","good_sort":99,"good_new":1,"good_promotion":1,"create_time":"1569222248"}

]

大概就是要批量刪除兩條記錄,然后死活無(wú)法傳值到后臺(tái),傳過(guò)去返回一看就是undefined,卡了一上午?。。?!

最后解決,之后就能獲取到傳的值了{(lán)"id":["1","2"]},當(dāng)然這里使用json_encode盡心json處理了

var data = checkStatus.data;
     var id = new Array();//這里還有個(gè)小插曲,創(chuàng)建空數(shù)組時(shí),必須使用Array、array就會(huì)報(bào)錯(cuò),笑哭了,底子不牢固啊
     console.log(JSON.stringify(data));
     for(var i in data){
      id[i] = data[i].good_id;
     }
     $.ajax({
      url:'',//后臺(tái)控制器
      type:'post',
      data:{
       'id':id
      },
      dataType:'json',
      success:function (msg) {
       console.log(msg);
      }
     }); 

以上這篇解決layui批量傳值到后臺(tái)操作時(shí)出現(xiàn)傳值為空的問(wèn)題就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持億速云。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI