select list sending old value in ajax request I have a select list on custom module form, on it's select giving ajax call and populating the second select list. But when I select the value from the first list, it is passing old value (previously selected) to the callback function (It should send currently select value).
Following is my code.

  function get_subject($form, &amp;$form_state) {
    $form['students'] = array(
      '#type' =&gt; 'select',
      '#options' =&gt; $student_array,
      '#title' =&gt; t('Students'),
      '#id' =&gt; 'students',
      '#value' =&gt; ($students != '') ? $students : '',
      '#required' =&gt; TRUE, 
      '#ajax' =&gt; array(
        'callback' =&gt; '_subject_loader',
        'wrapper' =&gt; 'subject_div',
      ),
    );
    $form['subject'] = array(
      '#type' =&gt; 'select',
      '#options' =&gt; $subject_list,
      '#title' =&gt; t('subject'),
      '#id' =&gt; 'subject',
      '#prefix' =&gt; '&lt;div id="subject_div"&gt;',
      '#suffix' =&gt; '&lt;/div&gt;',
      '#value' =&gt; ($subject != '') ? $subject: '',
      '#required' =&gt; TRUE 
    );
    $form['submit'] = array(
      '#type'=&gt;'submit',
      '#value'=&gt;'Submit',
    );
    return $form;
  }

  function _subject_loader($form, $form_state) {
    return $form['subject'];
  }
Use Form state input rather than using values in ajax call back like below:

if (isset($form_state['input']['students'])) {
    $student = $form_state['input']['students'];
  }