有我的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)}, }); }我得到這樣的結(jié)果:array(1) { ["{"product_id":"]=> array(1) { [""10","9""]=> string(0) "" }}如何在php中提取此代碼?
1 回答

汪汪一只貓
TA貢獻(xiàn)1898條經(jīng)驗(yàn) 獲得超8個(gè)贊
無(wú)需使用JSON.stringify,只需傳遞原始值數(shù)組即可:
$.ajax({
method: 'POST',
url : 'http://localhost/shop/ext/ajax/products_compare/test.php',
data: {product_id: chkArray},
});
在服務(wù)器端,您將擁有$_POST['product_id']帶有值的數(shù)組。
- 1 回答
- 0 關(guān)注
- 168 瀏覽
添加回答
舉報(bào)
0/150
提交
取消