请问用layui如何实现在弹出列表窗口中多选,然后返回并带回选中的所有值。

提问 未结 18 466
Gamebook
Gamebook 2019-10-3
悬赏:20飞吻
版本:layui 浏览器:
如题。希望可以有完整可用的示例代码,谢谢!
回帖
  • Gamebook
    2019-10-6
    @希望的曙光 再次感谢!我按您说的修改了:
    if($type=="city_json"){
    $json_data = json_decode('{"code": "0", "msg": "success", "data": [
    { "id": 1, "name": "北京" },
    { "id": 2, "name": "上海" },
    { "id": 3, "name": "广州" },
    { "id": 4, "name": "深圳" },
    { "id": 5,"name": "天津" },
    { "id": 6, "name": "南京" },
    { "id": 7, "name": "杭州" },
    { "id": 8, "name": "成都" },
    { "id": 9, "name": "石家庄" },
    { "id": 10, "name": "济南" },
    { "id": 11, "name": "沈阳" }
    ], "count": 11}', true);

    echo $json_data;
    }

    $json_data 打印出来是这样的:array (
    'code' => '0',
    'msg' => 'success',
    'data' =>
    array (
    0 =>
    array (
    'id' => 1,
    'name' => '北京',
    ),
    1 =>
    array (
    'id' => 2,
    'name' => '上海',
    ),
    2 =>
    array (
    'id' => 3,
    'name' => '广州',
    ),
    3 =>
    array (
    'id' => 4,
    'name' => '深圳',
    ),
    4 =>
    array (
    'id' => 5,
    'name' => '天津',
    ),
    5 =>
    array (
    'id' => 6,
    'name' => '南京',
    ),
    6 =>
    array (
    'id' => 7,
    'name' => '杭州',
    ),
    7 =>
    array (
    'id' => 8,
    'name' => '成都',
    ),
    8 =>
    array (
    'id' => 9,
    'name' => '石家庄',
    ),
    9 =>
    array (
    'id' => 10,
    'name' => '济南',
    ),
    10 =>
    array (
    'id' => 11,
    'name' => '沈阳',
    ),
    ),
    'count' => 11,
    )
    前端还是报错:parsererror

    改为:
    if($type=="city_json"){
    $json_data = json_encode(json_decode('{"code": "0", "msg": "success", "data": [
    { "id": 1, "name": "北京" },
    { "id": 2, "name": "上海" },
    { "id": 3, "name": "广州" },
    { "id": 4, "name": "深圳" },
    { "id": 5,"name": "天津" },
    { "id": 6, "name": "南京" },
    { "id": 7, "name": "杭州" },
    { "id": 8, "name": "成都" },
    { "id": 9, "name": "石家庄" },
    { "id": 10, "name": "济南" },
    { "id": 11, "name": "沈阳" }
    ], "count": 11}', true));

    echo $json_data;
    }

    $json_data打印出来是:
    '{"code":"0","msg":"success","data":[{"id":1,"name":"\\u5317\\u4eac"},{"id":2,"name":"\\u4e0a\\u6d77"},{"id":3,"name":"\\u5e7f\\u5dde"},{"id":4,"name":"\\u6df1\\u5733"},{"id":5,"name":"\\u5929\\u6d25"},{"id":6,"name":"\\u5357\\u4eac"},{"id":7,"name":"\\u676d\\u5dde"},{"id":8,"name":"\\u6210\\u90fd"},{"id":9,"name":"\\u77f3\\u5bb6\\u5e84"},{"id":10,"name":"\\u6d4e\\u5357"},{"id":11,"name":"\\u6c88\\u9633"}],"count":11}'

    前端还是报错:parsererror
    0 回复
  • @Gamebook url请求正确了吗,url参数里不要有php代码,只要请求路径
    0 回复
  • Gamebook
    2019-10-7
    @希望的曙光 url请求正确的,只有这样才能请求到正确的url,有打印出以上正确的$json_data的值就说明调用正确的。
    0 回复
  • Gamebook
    2019-10-8
    0 回复
  • Gamebook
    2019-10-8
    抛出的异常信息: 异常 - Cannot pass parameter 1 by reference
    0 回复
  • Gamebook
    2019-10-8
    以上两条回复作废,原因是 stuPractice2.php 中 if($type=="city_json"){ 中的代码乱掉了,现在代码已恢复为之前说的那样,仍然前端报错:parsererror。打印出来的$json_data还是如前所述。我朋友说是因为数据返回到前段时解析错误。前端_this.plugins.table.render({ 中 parseData: function(res) { console.log('res: ' + res); var data = decode(res.data); 也未打印出res的值。请赐教!
    0 回复
  • Gamebook
    2019-10-8
    以上两条回复作废,原因是 stuPractice2.php 中 if($type=="city_json"){ 中的代码乱掉了,现在代码已恢复为之前说的那样,仍然前端报错:parsererror。打印出来的$json_data还是如前所述。我朋友说是因为数据返回到前端时解析错误。前端_this.plugins.table.render({ 中 parseData: function(res) { console.log('res: ' + res); var data = decode(res.data); 也未打印出res的值。请赐教!
    0 回复
  • Gamebook
    2019-10-10
    @希望的曙光 可以了,十分感谢![微笑] 欢迎访问 www.gamebook.wiki 主机出租|象棋社|尔东返利网
    0 回复