X 可编辑 - 从 mysql 获取下拉选项

X editable - get dropdown option from mysql

我的数据库中有一个包列表。用户需要 select 他想使用什么包。我想使用 xeditable 下拉 bootsrap 但列表没有显示。总是 "error when loading list".

我在package.php

中有一个例子
function get_package(){
    $data = Array ( 
        array('value' => 1, 'text' => 'package1'),
        array('value' => 2, 'text' => 'package2'),
        array('value' => 3, 'text' => 'package3')
    );

    echo json_encode($data);
}

下面是我的js文件。

 $('#kitname').editable({
    value:1,
    source: 'package.php'
});

还有我的 html 文件。

     <a href="#" 
        id="kitname" 
        data-type="select"
        data-name="kitname" 
        data-pk="1" 
        data-value="5" 
        data-original-title="Select Package" 
        "> 
            Select Package 
    </a>

我这周需要一些时间来解决同样的问题,但解决方案很简单。 ;) 该数组仅包含:value => text:

function get_package(){
    $data = Array ( 
        array('1' => 'package1'),
        array('2' => 'package2'),
        array('3' => 'package3')
    );

    echo json_encode($data);
}