1

我正在处理一个 jquery 分页,其中我有 Json 响应来返回要加载到特定页面和其他支持绑定元素值中的数据。为此,我需要在每次点击页面时返回一个二维数组作为 Json 响应。我已经声明了二维数组并像下面一样返回它,我认为这样做是错误的,需要纠正。

我的php页面中的代码:

     header("Content-Type: application/json");   
 dataset array from which pagination will select the page data:

    $data = array("a","b","c","d","e","f","g","h","i","j",);

    2 dimensional array that I wish to return as response:

$response_multi = array(
    $currentPage,
    $hasNextPage,
    $hasPreviousPage,
    $maxPage,
    $dataCount,
    $dataResponse = array($pageSize),
    $pageSize   
);
    ######### variables and array within $response_multi array will be set and the return section is like ############

    echo json_encode($response_multi );

它不工作。请任何人!提前致谢。:)

4

1 回答 1

0

像这样试试

$pageSize = array(1,2,3,4)


$response_multi[] =  $currentPage;
$response_multi[] =  $hasNextPage;
$response_multi[] =  $hasPreviousPage;
$response_multi[] =  $maxPage;
$response_multi[] =  $dataCount;
$response_multi['dataResponse'] =  $pageSize;
$response_multi[] =  $pageSize;

echo json_encode($response_multi);
于 2013-07-25T04:52:43.860 回答