How to add extra arguments/parameters to ajax callback function? I am using drupal 7. I need to add extra arguments to my ajax callback function. I have five fieldsets in my form, and in all of them same there are same elements, just their IDs are different. For example; group-1, group-2... I need to include that 1,2,3.. part in the callback function as arguments. Otherwise, it will be too complicated to build a logic to predict which fieldset element need to change.

For example, is such a an implementation possible?

function mymodule_form($form, $form_state) {
    $group = 1;

    // Some form elements...

    $form['button'] = array(
        '#type' =&gt; 'button',
        '#ajax' =&gt; array(
            'callback' =&gt; 'my_callback_function',
            'wrapper' =&gt; 'my_target_area',
            'arguments' =&gt; array($group1, ...) // Is such a thing possible or another way? 
        ),
    );
}

function my_callback_function($args, $form, $form_state) {
    $arguments = $args;
    return $form['my_target_area'];
}


This question as already been asked here. But I those answers don't fit my needs mentioned above. Thank you.
Drupal doesn't have a mechanism to do that, no. As mentioned in the post you linked to, there's no need to pass that data to Javascript and then back to PHP though - just keep it in the form:

function mymodule_form($form, $form_state) {
  $form['button'] = array(
    '#type' =&gt; 'button',
    '#ajax' =&gt; array(
      'callback' =&gt; 'my_callback_function',
      'wrapper' =&gt; 'my_target_area',
    ),
  );

  $form['#foo'] = array($group1, ...);

}

function my_callback_function($form, $form_state) {
  $arguments = $form['#foo'];
  return $form['my_target_area'];
}