亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在php中提取json

在php中提取json

PHP
冉冉說 2021-04-09 14:15:55
有我的ajax代碼//If chkArray is not empty show the <div> and create the list        if(chkArray.length !== 0) {            $.ajax({                method: 'POST',                url : 'http://localhost/shop/ext/ajax/products_compare/test.php',//                data : JSON.stringify({product_id: chkArray})                data: {product_id: JSON.stringify(chkArray)},            });        }我得到這樣的結果:array(1) {  ["{"product_id":"]=>  array(1) {    [""10","9""]=>    string(0) ""  }}如何在php中提取此代碼?
查看完整描述

1 回答

?
汪汪一只貓

TA貢獻1898條經驗 獲得超8個贊

無需使用JSON.stringify,只需傳遞原始值數組即可:


$.ajax({

    method: 'POST',

    url : 'http://localhost/shop/ext/ajax/products_compare/test.php',

    data: {product_id: chkArray},

});

在服務器端,您將擁有$_POST['product_id']帶有值的數組。


查看完整回答
反對 回復 2021-04-23
  • 1 回答
  • 0 關注
  • 173 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號