您好我有以下
<script type='text/javascript'>if (dijit.byId('assignedUserId') != undefined) {
dijit.byId('assignedUserId').destroy();}require([ 'dojo/store/JsonRest',
'dijit/form/FilteringSelect', 'dojo/domReady!'], function(JsonRest, FilteringSelect){
var jsonRest = new JsonRest({ target: 'Welcome.do?call=JS&actionRefId=142' });
var filteringSelect = new FilteringSelect({ id: 'assignedUserId', name:
'assignedUserId', value: '25', store: jsonRest, searchAttr: 'name',
labelAttr: 'label' }, 'assignedUserIdSelect').startup();});
</script>
<input id='assignedUserIdSelect' name='value(assignedUserId)'/>
当我开始输入filteringselect时,它会调用URL并返回
{"identifier": "id", "label": "label", "items": [{ "name": "", "id": "0" , "label": "" },{
"name": "Lea M Test", "id": "26" , "label": "Lea M Test" }]}
但是没有任何内容填充到过滤选择中 - 服务器需要返回的json的格式是什么?
答案 0 :(得分:0)
尝试返回一个对象数组。快速测试是将您的JsonRest目标修改为一个简单的php文件。例如,如果您的服务器处理'.php'文件,请创建一个名为 Welcome.php 的文件,其中包含以下内容:
<?php
$data = '[{ "name": "Abi Normal", "id": "0" , "label": "Abi Normal" },{"name": "Lea M Test", "id": "26" , "label": "Lea M Test" }]';
echo $data;
?>
然后将您的JsonRest目标更改为 Welcome.php