want to load the multiple select box field data as per selected category using ajax form alter? I have list of select box like Team and Player with category option on top of the form. if i select the cricket in that category it should load players and Teams node title based on the category selected using ajax, i have done the ajax code but its working for only one field, please can onyone help to solve this

here is my complete code

function newname_form_alter(&amp;$form, $form_state, $form_id) {

  switch ($form_id) {
   case "loadtest_node_form":  // If the current edited page is an article form
    /*
    * The wrapper location is the entity reference field that contains the node titles
    * because that's where nodes listed needs to be restricted based on selection
    */
    $form['field_loadtest_player']['#prefix']='&lt;div id="jicustom_test_entity_wrapper"&gt;'; 
    $form['field_loadtest_player']['#suffix']='&lt;/div&gt;';
  $form['field_loadtest_team']['#prefix']='&lt;div id="jicustom_test_entity_wrapper1"&gt;'; 
    $form['field_loadtest_team']['#suffix']='&lt;/div&gt;';

 $form['field_loadtest_category'][LANGUAGE_NONE]['#ajax'] = array( // adding an ajax attribute
      'callback' =&gt; 'jicustom_test_entity_callback1',
      'wrapper' =&gt;'jicustom_test_entity_wrapper1',
      'method' =&gt; 'replace',  // the data would replace the field
      'effect' =&gt; 'fade',
      'event' =&gt; 'change',  // On change of the selection this action would take place
    );  
$form['field_loadtest_category'][LANGUAGE_NONE]['#ajax'] = array( // adding an ajax attribute
      'callback' =&gt; 'jicustom_test_entity_callback',
      'wrapper' =&gt;'jicustom_test_entity_wrapper',
      'method' =&gt; 'replace',  // the data would replace the field
      'effect' =&gt; 'fade',
      'event' =&gt; 'change',  // On change of the selection this action would take place
    );


// dpm($form);
    // Only when values are set in field_article_test_entity_type, should the options change
    // Also works for nodes that already have entity type selected
    if(!empty($form_state['values']['field_loadtest_player'])){
      $content_type = $form_state['values']['field_loadtest_category']['und']['0']['tid'];
      $form['field_loadtest_player']['und']['#options'] = jicustom_get_nodes($content_type);
    }
    if(!empty($form_state['values']['field_loadtest_team'])){
      $content_type = $form_state['values']['field_loadtest_category']['und']['0']['tid'];
      $form['field_loadtest_team']['und']['#options'] = jicustom_get_team($content_type);
    }
    break;
  }
}

/*
* Get List of node titles based on the content type
*/
function jicustom_get_nodes($content_type){

$result = db_query("SELECT n.title, n.nid
FROM node n
INNER JOIN field_data_field_category  ft ON n.nid = ft.entity_id
WHERE ft.field_category_tid = $content_type AND n.type='player'
ORDER by n.title ASC");
  foreach ($result as $record) {
    $nodes[$record-&gt;nid]=$record-&gt;title;
  }
  return $nodes;
}
function jicustom_get_team($content_type){

$result = db_query("SELECT n.title, n.nid
FROM node n
INNER JOIN field_data_field_category  ft ON n.nid = ft.entity_id
WHERE ft.field_category_tid = $content_type AND n.type='team'
ORDER by n.title ASC");
  foreach ($result as $record) {
    $nodes[$record-&gt;nid]=$record-&gt;title;
  }
  return $nodes;
}
function  jicustom_test_entity_callback($form, $form_state){
  return $form['field_loadtest_player'];

}
function  jicustom_test_entity_callback1($form, $form_state){
 return $form['field_loadtest_team'];

}
Use reference &amp;$form_state instead of $form_state in functions
hook_form_alter(&amp;$form, &amp;$form_state, $form_id)

Edit:
Ohh yes, I got, there is one should be field_loadtest_player you used "field_loadtest_category" on both ajax
$form['field_loadtest_player'][LANGUAGE_NONE]['#ajax'] = array( 
   ...
   ...
);
$form['field_loadtest_category'][LANGUAGE_NONE]['#ajax'] = array( 
   ...
   ...
);