Can a form triggering an ajax call reload itself on drupal 7? I'm trying to built a page to ask questions with a stream on top, so I need ajax to avoid the reload. It is actually simple. On top is a node with the stream and I add to blocks beneath. 


A table with the questions, number of votes for the questions and an "add vote" button
A form to add a new node "question with 0 votes"


I have two problems.

A)When I click on the submit button of the 2. Block I add a question, I can update the table with the new question, but the add question form is not being emptied.

B)When I add a vote on the table (currently an ajax call from a checkbox) I get the database to have an increased counter and as far as I could check the callback delivers the new table, but the old one is never replaced. I thought it was the cache, but I even managed to avoid using the cached one, still no replacement. I get a few headers allready sent notices, but I don't understand why. I just want the form to be replaced by the new one.

(don't mind me getting a view instead of just a database result, it's just to built the table)

function questions_list_voting_form($form, &amp;$form_state){
global $user;
$form['#prefix'] = '&lt;div id="questions-list-table"&gt;';
$form['#suffix'] = '&lt;/div&gt;';
$form['table'] = array(
        '#tree' =&gt; TRUE,
        '#theme' =&gt; 'table',
        '#header' =&gt; array(t("Title"),t("Votes"),t("Add vote")),
        );
    $view = views_get_view('questions_view');
}
$view-&gt;is_cacheable = FALSE;
$view-&gt;execute('block');
foreach ($view-&gt;result as $row){
    //['rows']['row-'.$row-&gt;nid]
    $question = array('#markup'=&gt;$row-&gt;node_title);
    $vote = array('#markup'=&gt;$row-&gt;field_data_field_votes_field_votes_value);
    $addvote = array(
    '#type'=&gt;'checkbox',
        '#return_value' =&gt; 'add_vote'.$row-&gt;nid,
    '#ajax' =&gt; array(
      'callback' =&gt; 'ajax_addvote_callback',
      'wrapper' =&gt; 'question-list-table',
        'effect' =&gt; 'slide',
    ));
    $tab_arr = array(
            'question' =&gt; &amp;$question,
            'vote' =&gt; &amp;$vote,
            'addvote'.$row-&gt;nid =&gt; &amp;$addvote
    );
    $tab_rows = array(
            array('data' =&gt; &amp;$question),
            array('data' =&gt; &amp;$vote),
            array('data' =&gt; &amp;$addvote),
    );
            $form['table'][] = $tab_arr;
    $form['table']['#rows'][] = $tab_rows;
    $form['redirect'] = FALSE;
    $form['#rebuild'] =TRUE;
    unset($question);
    unset($vote);
    unset($addvote);
       }
     return $form;
}
function questions_list_voting_form_submitx($form, $form_state){
   if(substr($form_state['triggering_element']['#value'],0,8) == 'add_vote'){
    $tmp_node = node_load(substr($form_state['triggering_element']['#value'],8,2)); //question node
    $tmp_node-&gt;field_votes['und'][0]['value']++;
    node_save($tmp_node);
   }
}
function ajax_addvote_callback($form, &amp;$form_state){
questions_list_voting_form_submitx($form, $form_state);
$form_state['no_redirect'] = TRUE; // avoid redirect?? maybe not working
$form_state['input'] = array('test'=&gt;'etch'); //something to avoid cache 
$form = drupal_build_form('questions_list_voting_form', $form_state);
$form_html = drupal_render($form);
return $form_html; 
}
Your form id is 'questions-list-table' but you have 'wrapper' => 'question-list-table' (letter s is missing). You might also want to be explicit with 'method' => 'replace' since the ajax is causing problems.

You should add a '#submit' => 'submit_function' and modify your $form_state in that function instead of trying to modify it in the ajax callback.

Why do you rebuild and render the form in your ajax callback? I think you just want to return the part of the form to replace - in this case, $form itself.