xajax problem with drupal 5.x
snowwind - June 4, 2007 - 10:20
I make some text but it doesn't work so i hope someone give me your advice. please tell me where have problem.my code blew:
require_once('inc/xajax.inc.php' );
/**
* Implementation of hook_help().
*/
/**
* Display help and module information
* @param section which section of the site we're displaying help
* @return help text for section
*/
function mymodule_help($section='') {
$output = '';
switch ($section = '') {
case "admin/help#xajax":
$output = '<p>'. t("Adds xajax support to your modules."). '</p>';
break;
}
return $output;
} // function xajax_help
/**
* Implementation of hook_menu().
*/
function mymodule_menu($may_cache) {
// initialise xajax
$path = drupal_get_path('module', 'mymodule');
require_once($path . "/inc/xajax.inc.php");
$xajax = new xajax();
$xajax->registerFunction("mymodule_dosomething");
drupal_set_html_head("<script type=\"text/javascript\" src=\"". base_path() . $path . "/inc/xajax_js/xajax.js\"></script>");
$xajax->processRequests();
$items[] = array(
'path' => 'xajax',
'callback' => 'xajax_hello',
'access' => user_access('receive xajax'),
'type' => MENU_NORMAL_ITEM
);
return $items;
}
function xajax_hello_form() {
$path = drupal_get_path('module', 'mymodule');
require_once($path . "/inc/xajax.inc.php");
$form['name'] = array (
'#type' => 'fieldset',
'#title' => 'text this'
);
$form['name']['text'] = array(
'#type' => 'textfield',
'#title' => t('this')
);
$form['name']['submit'] = array(
'#type' => 'submit',
'#value' => 'text',
'#attributes' => array('onclick'=>'javascript:xajax_mymodule_dosomething(); return false;')
);
return $form;
}
function xajax_hello() {
return drupal_get_form(xajax_hello_form);
}
function mymodule_dosomething(){
$objResponse = new xajaxResponse();
$objResponse->addAlert("You pressed da button");
return $objResponse->getXML();
}