How to pass multi-dimensional array with Jquery AJAX post?

前端 未结 6 1110
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-31 17:17

I\'ve been using Serialize() to pass checkbox form data with Post() for a basket that can hold multiple items of the same category.

When I post them using the submit

6条回答
  •  被撕碎了的回忆
    2020-12-31 17:49

    $.post(url, {"myarray":arrayData}, function(data){/*stuff*/}, 'json');
    

    server side you would access it for example with php

    $myArray = $_POST['myarray'][0];
    foreach($myArray as $item)
    {
       /*logic here for picking apart your array*/
    }
    

提交回复
热议问题