我已经尝试了所有方法来让它填充组合下拉框。键入时,说“Apple”,它似乎正在加载数据,但下拉框中没有任何内容。Firebug 显示数据已加载。那么,我哪里错了?谢谢。
Ext.create('Ext.form.field.ComboBox', {
fieldLabel: 'Basket',
emptyText : 'Type a fruit name',
queryMode : 'remote',
minChars : 3,
fields : ['id', 'name'],
store : {
proxy: {
type: 'jsonp',
callbackKey: 'method',
url: 'http://www.comparetrainfares.co.uk/train_scripts/data.php',
reader: {
root: 'items'
},
}
},
needleKey : 'query',
labelKey : 'id',
label : 'name',
displayField : 'name',
width : 260,
forceSelection: true,
renderTo : query1,
});
<?php
header('Access-Control-Allow-Origin: *');
//header('Content-Type: application/json; charset=utf8');
//header('Content-Type: application/x-json');
// http://www.comparetrainfares.co.uk/train_scripts/data.php
$output = array();
$output[] = array('id' => '1', 'name' => 'Apple');
$output[] = array('id' => '2', 'name' => 'Banana');
$output[] = array('id' => '3', 'name' => 'Orange');
$output[] = array('id' => '4', 'name' => 'Lemon');
$objects = array('items' => $output);
echo json_encode($objects);
?>