Drupal7のAjaxオートコンプリートテキストフィールドはFirfoxで機能しますが、IEとChromeでは機能しません。次のエラーが表示されます。
AJAXHTTPエラーが発生しました。HTTP結果コード:200デバッグ情報は次のとおりです。
パス:http:// localhost / drupal / en / example / autocomplete
StatusText:OK
ResponseText:{"admin": "admin"、 "alex": "alex"、 "apple": "apple"}
function clubform_menu() {
$items['example/autocomplete'] = array(
'page callback' => '_module_name_autocomplete',
'access arguments' => array('access example autocomplete'),
'type' => MENU_CALLBACK
);
return $items;
}
function _module_name_autocomplete($string) {
$matches = array();
$return = db_query("SELECT name FROM users where lower(name) like '".$string."%' LIMIT 10");
// add matches to $matches
foreach ($return as $row) {
$matches[$row->name] = check_plain($row->name);
}
// return for JS
drupal_json_output($matches);
}
...
$form['editclub']['club_name'] = array(
'#title' => t(''),
'#type' => 'textfield',
'#description' => t(''),
'#autocomplete_path' => 'example/autocomplete',
'#weight' =>15,
'#size' => 30,
);
...
Firefoxでの出力は次のとおりです。