我有这个静态代码,可以很好地生成一个下拉菜单,用于内联编辑。
<script>
$('.editable_selectfield_1').editable({
source: [
{value: '1', text: 'Overig'},
{value: '2', text: 'Constructiestaal'},
{value: '3', text: 'Constructiestaal (fijn)'},
{value: '4', text: 'Ketelplaat'},
{value: '5', text: 'Ketelplaat (ASME)'},
{value: '6', text: 'Ketelplaat (fijn)'},
{value: '7', text: 'Scheepsbouw'},
{value: '8', text: 'Hoge sterkte'},
{value: '9', text: 'Slijtvast'},
{value: '10', text: 'RVS'},
{value: '11', text: 'Offshore'},
],
});
</script>但是我需要这个动态的,所以我已经将内容移到一个新的文件includes/test.php中进行测试,我已经将内容放置在那里,就像这样
<?php
echo "
{value: '1', text: 'Overig'},
{value: '2', text: 'Constructiestaal'},
{value: '3', text: 'Constructiestaal (fijn)'},
{value: '4', text: 'Ketelplaat'},
{value: '5', text: 'Ketelplaat (ASME)'},
{value: '6', text: 'Ketelplaat (fijn)'},
{value: '7', text: 'Scheepsbouw'},
{value: '8', text: 'Hoge sterkte'},
{value: '9', text: 'Slijtvast'},
{value: '10', text: 'RVS'},
{value: '11', text: 'Offshore'},
";
?>现在我已经将脚本更改为
<script>
$('.editable_selectfield_1').editable({
source: [('includes/test.php').load]
});
</script>我在控制台中没有错误。但是列表是空的。有什么建议吗?

发布于 2020-02-27 13:03:57
使用PHP包括
source: [<?php include_once 'includes/test.php'?>]
https://stackoverflow.com/questions/60433528
复制相似问题