Drupal 7 Block配置AJAX

I'm building a custom block programmatically that has two select boxes. The first one is populated automatically and the second is populated based on the value of the first. Ideally I'd like to use AJAX and I have experience integrating AJAX in a standard form, however the block configuration form doesn't include a $form_state variable and seems to function differently. Can the standard method be used?

'#ajax'               => array(
  'callback'          => 'my_callback',
  'wrapper'           => 'the-id',
  'method'            => 'replace',
  'effect'            => 'fade',
),

How would the callback work?

Thanks, Howie

I didn't try this but I bet it works: use hook_form_alter() to access your block configuration form. There, you will have a &$form_state and be able to do fancy AJAX stuff (see this). The hard part is to ONLY alter YOUR form at the alter-hook. Possible ways:

Not sure if this works (most elegant way):

 function mymodule_form_alter(&$form,&$form_state,$form_id) {
      if ($form_id == 'block_admin_configure' ) {
        // Find the delta in the $form variable
        if ($form['delta'] == 'the_delta_you_are_looking_for') {
         //do fancy ajax stuff
        }
      }
    }

Ugly but definitely possible:

function mymodule_form_alter(&$form,&$form_state,$form_id) {
  if ($form_id == 'block_admin_configure' && arg(4) == 'mymodule') {
       //do fancy ajax stuff
    }
  }
}

Even uglier but also possible:

function mymodule_block_configure($delta = '') {      
    $form = array();
    if ($delta == 'my_block') {
        $form["my_block_change_this"] = array(
            "#type" => "hidden",
            "#value" => "lalala",
        )
    }
}

function mymodule_form_alter(&$form,&$form_state,$form_id) {
    if ($form_id == 'block_admin_configure' ) {
        if (!empty($form['my_block_change_this'])) {
            //do fancy ajax stuff
        }
    }
}

Tip: Print out the form_state-array (at the alter hook) and see what's there (That's always the first thing I do when I run into FAPI-Issues). Hope this helps.