为了账号安全,请及时绑定邮箱和手机立即绑定

在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 关注
  • 154 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信