Alert a message after ajax callback I would like to implement something like the second example in this link but not when the form is submitted, actually when a radio button is clicked. (click to alert) http://d7.drupalexamples.info/examples/ajax_example/advanced_commands. With the code below i managed to alert the message but after that the form does not work properly, after the submit it redirects me to $base_url/system/ajax and a json array is displayed.

$form['submitted']['test']['#ajax'] = array
        (
           'callback' =&gt; '_test',
           'wrapper' =&gt; 'nimportequi',
           'progress' =&gt; array('type' =&gt; 'throbber', 'message' =&gt; '')
        );


and the callback:

function _test($form, $form_state){
    $commands = array();
     $text = "";
     $alert = 0;
     if (valid_email_address($form['submitted']['email']['#value']) !== FALSE)
     {
        $result = user_load_by_mail($form['submitted']['email']['#value']);
        $text = ($result !== FALSE)?$alert=1:"Based on your email, you are not a member yet!";
     }
     else 
        $text = "Based on your email, you are not a member!";
     if ($alert != 1 &amp;&amp; $form_state['values']['submitted']['member'] == 1)
     {
        $commands[]=ajax_command_alert($text);
       // $commands[] = ajax_command_data("#foo", 'label_radio', '1');
     }
     $form_state['rebuild'] == TRUE;
     return array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);
}


Also i am using a rule when the form is submitted. What am i doing wrong ? I cannot figure it out…
Add the ajax callback in the submit button of the form like this:

Edit

$form['radio_buttons']['#ajax'] = array (
  'callback' =&gt; '_test',
  'wrapper' =&gt; 'nimportequi',
  'event' =&gt; 'change',
  'progress' =&gt; array('type' =&gt; 'throbber', 'message' =&gt; ''),
);


This will ensure that when a radio button is clicked your ajax callback will be executed. Selecting radio buttons will give alert message, therefore the ajax callback should be applied to radio buttons.

Your ajax callback seems ok.