Domanda

An Ajax Autocomplete Textfield In Drupal 7 works in Firfox, but doesn't work in IE and Chrome. The following error appears:

An AJAX HTTP error occured. HTTP Result Code: 200 Debugging information follows.
Path: 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, 
         );
...

The output in Firefox is the following: enter image description here

È stato utile?

Soluzione

I found out what causes AJAX error! When I turn on any module with utf8 incoding it causes the error, when i change the encoding to ANSI or to utf8 without BOM, everything works. This incoding problems happened only in Google chrome, in Firefox all encodings work well

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top