How PHP receives the secondary array submitted by the front end

post submits a two-dimensional array,

    $.post(url, $("-sharporderForm").serialize(), function (data) {
        if (data.status == 0) {
            $(".tank-tishi-main-con-txt").html("" + msg);
            $(".tank-tishi-main").show();
            setInterval("window.order.reduce(" + state + ")", 1000);
        } else {
            layer.msg("");
        }
    }, "json");

the format of the packet grab request is as follows

skuList[0].goods_id: 1
skuList[0].color: 113_
skuList[0].goods_remark: 
skuList[0].21_M: 
skuList[0].22_L: 
skuList[0].23_XL: 
skuList[0].24_XXL: 
skuList[0].25_XXXL: 
skuList[0].26_4XL: 
skuList[0].27_SS: 
skuList[0].28_S: 
skuList[0].29_M: 
skuList[0].210_L: 
skuList[0].211_XL: 
skuList[0].212_XXL: 

the php end receives it with $_ POST, and the print result is

.
Array
(
    [0] => 
)

unable to receive data, how do I receive it?

Mar.14,2021

the problem is not php, but at your front end.

jQuery.js supports multidimensional arrays, and ajax encapsulated by other libraries may not support it.
but use serialize () to get a string like a=33&b=44, while an and b correspond to the name, owner in the form form to take out your html part of the code.

there are only two ways for PHP to receive post data: (the landlord is not using a lower version of php, is it?)

  1. $_ POST
  2. $post=file_get_contents ("php://input") receives data in the form of a stream, such as axios.js, which is required by default.

in general, ajax in jquery.js only needs to use $_ POST.

if not, you should have changed the default configuration, so try it in the second way.

in addition, I am still very interested. How did the landlord get the two-dimensional array through serialize ()?


js splicing to json submission.


the problem lies in the request parameters. Change the form parameters to a full array to receive OK

skuList[0][goods_id]: 1
skuList[0][color]: 113_
skuList[0][goods_remark]: 
.......
Menu