I added a class use-ajax to a link but Its not updating the wrapper `div. My Code is:
function custom_menu(){
$items['testing'] = array(
'page callback' => 'articlenodeform',
'access arguments' => array('access content'),
);
$items['customajaxcallback'] = array(
'page callback' => 'custom_ajaxcallback',
'access arguments' => array('access content'),
);
return $items;
}
function articlenodeform(){
drupal_add_library('system', 'drupal.ajax');
drupal_add_js('misc/ajax.js');
$link = l(t('Say Hello'), 'customajaxcallback/ajax', array('attributes' => array('class' => 'use-ajax')));
return '<div>'.$link.'</div><div id="sayinghello"></div>';
}
function custom_ajaxcallback($type = 'ajax') {
if($type == 'ajax') {
$output = t('Hello World!');
$command = array();
$commands[] = ajax_command_append('#sayinghello', $output);
$page = array('#type' => 'ajax', '#ajax_command' => $commands);
ajax_deliver($page);
}
else{
return t("Hello world in new page.");
}
}
