jQuery: What to do with the list that sortable('serialize') returns?

前端 未结 8 1507
我寻月下人不归
我寻月下人不归 2020-12-23 20:01

With jQuery I\'m retrieving positions of a sortable list using \'serialize\', like this:

var order = $(\'ul\').sortable(\'serialize\');

The vari

8条回答
  •  不知归路
    2020-12-23 20:30

    if data is

    $data = 'album[]=stat&sort[]=157204&sort[]=157205&sort[]=157206&sort[]=157208&sort[]=157207&sort[]=157209&sort[]=157210&sort[]=157211&sort[]=157212&sort[]=157213';

    and you want to get sort as array in php
    use parse_str()
    parse_str($data, $output);
    print_r($output);

    Output : Array ( [album] => Array ( [0] => stat )

    [sort] => Array
        (
            [0] => 157204
            [1] => 157205
            [2] => 157206
            [3] => 157208
            [4] => 157207
            [5] => 157209
            [6] => 157210
            [7] => 157211
            [8] => 157212
            [9] => 157213
        )
    

    )

提交回复
热议问题