您好,登錄后才能下訂單哦!
如圖,前臺的樣子,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批量傳值到后臺操作時出現傳值為空的問題就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。