有我的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']帶有值的數組。
- 1 回答
- 0 關注
- 173 瀏覽
添加回答
舉報
0/150
提交
取消