Strange problem with autocomplete field in forms in Drupal 7 I have an autocomplete field, which has been working perfectly for 1-2 days. Suddenly, it stoped working. I re-wrote the code, cleared the cache, and it works again. After comparing code, it is exactly the same code. I cannot trace the error. The problem is that it does not give back any results and the Firebug error is:


  TypeError: matches is null if (typeof matches.status == 'undefined' || matches.status != 0) ...


I cannot understand why it suddenly stopped working.

I have traced back the problem to a warning by Drupal: 


  Warning: call_user_func_array() expects parameter 1 to be a valid callback, function '_search_idiomas_autocomplete/list/confirm/' not found or invalid function name in menu_execute_active_handler()


Still not sure where the problem is. The code is standard autocomplete field from official documentation examples.
I have finally completely solved the issue. I copy the code which is working and below the code which was giving the error. Please some expert on Drupal to verify if I am right:

Working code:
 $items['especialURL/autocomplete/%'] = array(

'page callback' => '_mymodule_autocomplete' ,
 'page arguments' => array(2,3,4),

Wrong code:

$items['especialURL/autocomplete'] = array(
   'page callback' => '_mymodule_autocomplete' . '/' . arg(2) .'/'.arg(3) . '/' . arg(4),

Explanation: the wrong code worked perfectly but once I cleared cache, it stopt working. Somehow the page callback was registered until the cache was emptied, and from that moment it would stop working. Maybe starting with page callback in the form of _mymodule_autocomplete and later adding the args() would work for a while. Interesting. These have been the worst 5 hours of my life working with Drupal due to using the wrong code while I had got it to work just by chance!!!