Ho un bel quesito per la comunità: come faccio ad usare ajax con drupal 6 nella visualizzazione di una funzione?
Il codice è questo e funziona bene, è una tabella paginata e ordinabile:
<?php
function role_show_role() {
global $language;
$header = array(
array('data' => t('Cid'), 'field' => 'cid', 'sort' => 'asc'),
array('data' => t('Rid'), 'field' => 'rid', 'sort' => 'asc'),
array('data' => t('Name'), 'field' => 'name', 'sort' => 'asc'),
);
$query = "SELECT rid, name FROM {role}";
$query .= tablesort_sql($header, $before='name,');
$result = pager_query($query, 25);
while ($row = db_fetch_array($result)) {
$rows[] = array($row['cid'], $row['rid'], $row['name']);
}
if (!$rows) { $rows[] = array(array('data' => t('Non ci sono record in questa tabella'), 'colspan' => 3)); }
$output = theme('table', $header, $rows);
$output .= theme('pager', NULL, 25, 0);
print theme('page', $output);
exit;
}
?>
Come posso utilizzare drupal_json(array('status' => TRUE, 'data' => $output)); oppure drupal_json($output); e dove per avere il risultato in ajax?