How to get success message in popup using custom form? How to get success message in popup form  here is my code :

   &lt;?php
 /**
 * Implements security_settings_form().
*/
function security_settings_block_info() {
$blocks['testing'] = array(
'info' =&gt; t('testing1'), 
'cache' =&gt; DRUPAL_NO_CACHE, //there are a number of caching options for this
 );

 return $blocks;
 }

function security_settings_block_view($delta = ''){
  switch($delta){
    case 'testing':
  if(user_access('access content')){ //good idea to check user perms here
     $block['subject'] = t('testing');
     $block['content'] = drupal_get_form('security_settings_form');
     //$block['content'] = security_settings_form();
     return $block;
  }
  break;
  }
  }
function security_settings_form($form, &amp;$form_state) {  
$form["wrapper"] = array("#markup" =&gt; "&lt;div id='test-ajax'&gt;&lt;/div&gt;");

   $result = db_select('taxonomy_term_data', 'ttd');
  $result-&gt;fields('ttd');
  $result-&gt;condition('ttd.vid', 2, '=');
  $results = $result-&gt;execute()-&gt;fetchAll();
   $termName = '';
   foreach($results as $record){    

   $v[]=$record-&gt;name;


}
$form['cities'] = array(
'#type' =&gt; 'select',
'#title' =&gt; t('Click on your city'),
//'#multiple' =&gt; true,
'#options' =&gt; $v,

 '#attributes' =&gt; array('class' =&gt; array('my-class-1')),
  );
   $form['email'] = array(
   '#type' =&gt; 'textfield',
   '#title' =&gt; t('Enter email'),

   '#validate' =&gt; array('security_settings_form_validate'),
 );  
    $form['save'] = array(
    '#type' =&gt; 'button',

    '#value' =&gt;  'Save',

     "#ajax" =&gt; array(
  "callback" =&gt; "dr_search_test_form_callback", 

  "wrapper" =&gt; "test-ajax",
  "effect" =&gt; "fade")

    );

return $form;
 }

function security_settings_form_validate($form, &amp;$form_state) {
$email = $form_state['values']['email'];

 // Verify that the email address is valid.
   if (!valid_email_address($email)) {
  form_set_error('email',('You must provide a valid email address.'));
  }

}

  function dr_search_test_form_callback($form, $form_state) {


   global $user; 
   $v=db_insert('security_settings')
   -&gt;fields(array(
  'uid' =&gt; $user-&gt;uid,
  'email' =&gt; $form_state['values']['email'],   
  'cities' =&gt; $form_state['values']['cities'],
    ))-&gt;execute();


   $email = $form_state['values']['email'];
   if (valid_email_address($email)) {
   $message = array('A new entry has been submitted');
   $to = 'abc@gmail.com';
   $params = array(
    'body' =&gt; $body,
    'subject' =&gt; 'Website Information Request',
     );
       if (drupal_mail('security_settings', 'some_mail_key',   $to,          language_default(), $params)) {
    drupal_set_message('Thanks, email sent.');  //success message  
   } else {
    drupal_set_message('Email not sent.');
  }
  }

return "&lt;div id='test-ajax'&gt;".$v."&lt;/div&gt;";
  }
 function security_settings_mail($key, &amp;$message, $params) {
   $message['subject'] = $params['subject'];
   $message['body'] = $params['body'];
  }
You can return the messages to the ajax form by adding the following to your ajax callback function (you'll need to remove your current return value)

$messages = array('#theme' =&gt; 'status_messages');
$commands = array();
$commands[] = ajax_command_prepend('#form_id', render($messages));

return array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);


Make sure to change #form_id to the actual ID of your form, or use whatever jQuery selector you want to prepend the messages to.