How do other modules update elements using AJAX callbacks? I have a block, of which I want to update the contents via AJAX. So the block is:

$block['subject'] = t('My Block');
$block['content'] = '&lt;div id="block_wrapper"&gt;&lt;/div&gt;';


And the form element AJAX part:

$form['select_element']['#ajax'] = array(
  'callback' =&gt; 'ajax_callback',
  'wrapper' =&gt; 'block_wrapper',
  'method' =&gt; 'replace',
);


The callback:

function ajax_callback($form, $form_state) {
  return views_embed_view('view_name', 'default', $form_state['values']['select_element']);
}


However when I change the form element the whole block content is replaced and the wrapper is replaced by a empty div, so subsequent alterations of the select element fail to update the block. 

The wrapper documentation explains the entire div is replaced, not just it contents. But many modules (like for example Views) have dynamically updating form elements where changing a select element toggles other parts of a form, which keeps working no matter how often you change it. Do they insert the wrapper div again in the response? And how should I alter the response of views_embed_view to put the contents in a wrapper div?
Thanks @Tasneem for directing me. I did it as follows:

function hook_form() {
  $form['select_element'] = array(
    '#type' =&gt; 'select',
    '#options' =&gt; $options,
    '#default_value' =&gt; $default,
    '#ajax' =&gt; array(
      'callback' =&gt; 'ajax_callback',
      'wrapper' =&gt; 'block_wrapper',
      'method' =&gt; 'replace',
    ),
  );

  $form['block_wrapper'] = array(
    '#type' =&gt; 'item',
    '#title' =&gt; t('Contents'),
    '#id' =&gt; 'block_wrapper',
    '#markup' =&gt; views_embed_view(...),
  );

  return $form;
}


function ajax_callback($form, $form_state) {
  $form['block_wrapper'] = array(
    '#type' =&gt; 'item',
    '#title' =&gt; t('Contents'),
    '#id' =&gt; 'block_wrapper',
    '#markup' =&gt; views_embed_view(...),
  );

  // Returning the entire $form here made the select element appear twice, so only return the wrapper element.
  return $form['block_wrapper'];
}