ajax request only the first time works? I have made an ajax request to update the select options based on the first select field selection

but the respond only works fine with the first request despite being seen with firebug

help me solve it please

thanks in advance

here is the code

 function listings_form_alter(&amp;$form,&amp;$form_state,$form_id){
    $governments=array();
  if($form_id == 'place_node_form' &amp;&amp; arg(1)=='add' &amp;&amp; arg(2)=='place'){
    $vocabularies=taxonomy_get_vocabularies();

  foreach($vocabularies as $vocab){
      if($vocab-&gt;machine_name =='governorates'){
          $_SESSION['vid']=$vocab-&gt;vid;
          break;
      }
  }
        $options=array(0=&gt;'choose gov');
  $g=taxonomy_get_tree($_SESSION['vid'],0,1,FALSE);
  $x=count($g);
  for($i=0;$i&lt;$x;$i++){
                  $options[$g[$i]-&gt;tid]=$g[$i]-&gt;name;
  }



   $form['gov']=array('#title'=&gt;'Gov','#name'=&gt;'governorate'
,'#type'=&gt;'select','#options'=&gt;$options
     ,'#ajax'=&gt;array('callback'=&gt;'ajax_callback',
  'event'=&gt;'change','wrapper'=&gt;'replace','method'=&gt;'html'));

 $op=array(0=&gt;'choose city');
$form['city']=array("#title"=&gt;'City','#name'=&gt;'city',
'#type'=&gt;'select','#prefix' =&gt; '&lt;div id="replace"&gt;',
'#suffix' =&gt; '&lt;/div&gt;','#options'=&gt;$op);

function ajax_callback($form_state,&amp;$form){

$childs_obj=  taxonomy_get_children($_POST['governorate'],$_SESSION['vid']);
foreach($childs_obj as $child_item){
    $op[$child_item-&gt;tid]=$child_item-&gt;name;
}

$form['city']=array("#title"=&gt;'City','#name'=&gt;'city','#type'=&gt;'select','#prefix' =&gt; '&lt;div id="replace"&gt;',
        '#suffix' =&gt; '&lt;/div&gt;','#options'=&gt;$op);
return array(
'#type'=&gt;'ajax', '#commands'=&gt;array(ajax_command_html("#replace", render($form['city'])),
ajax_command_alert($_POST['governorate'])
    )


);
?>
Please see http://drupal.org/coding-standards, as it is hard to read.

However that said, I usually find if ajax is only working once then as the element is replaced Drupal gives it a unique id which then breaks a selector. For example #form after the ajax request becomes #form-1 and is no longer targeted. -check for this in firebug