You are here

function ajax_poll_callback in AJAX Poll 6

Same name and namespace in other branches
  1. 7 ajax_poll.module \ajax_poll_callback()

Menu callback for poll/ajax.

1 string reference to 'ajax_poll_callback'
ajax_poll_menu in ./ajax_poll.module
Implements hook_menu().

File

./ajax_poll.module, line 95
Enables voting on polls without reloading the page.

Code

function ajax_poll_callback($type, $node, $teaser, $block) {

  // Call poll_view to trigger the current submit handlers.
  poll_view($node);

  // Reset POST and the $node so that we get fresh copies.
  unset($_POST);
  $node = node_load($node->nid, NULL, TRUE);
  $poll = poll_view($node, $teaser, FALSE, $block);
  $status = count(drupal_get_messages('error', FALSE)) == 0;
  $messages = theme('status_messages');
  $output = drupal_render($poll->content);
  drupal_json(array(
    'status' => $status,
    'messages' => $messages,
    'output' => $output,
  ));
}