2011-10-22 30 views
0

Ajax自動填充文本字段在Drupal 7中,它在Firfox中工作,但在IE和Chrome中不起作用。出現 以下錯誤:Drupal 7中的Ajax自動填充文本字段在Chrome中不起作用

的AJAX HTTP時發生錯誤。 HTTP結果代碼:200調試信息如下。
路徑:http://localhost/drupal/en/example/autocomplete
狀態文本:OK
的responseText:{ 「admin」 的: 「管理員」, 「亞歷克斯」: 「亞歷克斯」, 「蘋果」: 「蘋果」}

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是如下:enter image description here

+0

檢查了Drupal 7 AJAX示例,它們在Chrome中返回相同的錯誤。 – Alex

+0

這個怎麼樣? [http://drupal.stackexchange.com/questions/32463/create-textfieled-in-select-option-item-change][1] [1]:HTTP:// drupal.stackexchange.com/questions/32463/create-textfieled-in-select-option-item-change – zhilevan

回答

0

我發現了什麼導致AJAX錯誤!當我使用utf8開啓任何模塊時,它會導致錯誤,當我將編碼更改爲ANSI或不使用BOM時,utf8一切正常。這種惡化問題只發生在谷歌瀏覽器中,在Firefox所有編碼中都運行良好