By drupal_bineec on
All,
I am trying to implement AHAH in my custom module but some how it always throws HTTP 404 error. Can some one please look at my code and tell me whats going wrong here. I may have implemented completly wrong.
Thanks in advance
$items[] = array(
'path' => 'admin/get_states',
'page callback' => address_states',
'type' => MENU_CALLBACK,
);
function address_states()
{
return '<div>Some sample ahah content, from the server</div>';
}
$fields['address']['samples'] = array(
'#value' => '',
'#prefix' => '<div id="sample-ahah-samples">',
'#suffix' => '</div>',
);
$fields['address']['country'] = array(
'#type' => 'select',
'#title' => t('Country'),
'#description' => t('Country.'),
'#required' => TRUE,
'#options' => $country,
'#ahah' => array(
'path' => 'admin/get_states',
'wrapper' => 'sample-ahah-samples',
'progress' => array('type' => 'bar', 'message' => t('Please wait...')),
'method' => 'replace',
),
);
Comments
If you are using drupal 6
If you are using drupal 6 the path is wrong it needs to be in the items as the key for the array as below:
It changed in Drupal 6 compared to Drupal 5 and below.
Darren Ferguson
OpenBand / M.C.Dean
Thanks for the response, I
Thanks for the response, I did change the path but still it gives me the error.
error:
An error occured.
/drupal-6.2/admin/get_states
{Html here}
did you rebuild the menus,
did you rebuild the menus, eg, run the 'Rebuild menus' command from the Dev module?
I feel your AHAH pain -- it should be easier . . .
geremy
I enabled/disabled the
I enabled/disabled the module and tested it, still it didnt help. How to run 'Rebuild menus' command?
Enabling and disabling will
Enabling and disabling will rebuild the menu for you.
Are you seeing anything in the request i.e if your using Firefox does firebug on the console display any information, maybe a 404 message or something.
Also do you have the base path for your site i.e. i use /d6 as my base path and not just the site name i.e. http://example.com/d6 so /d6 is the base path for my ajax requests and not http://example.com/
Darren Ferguson
OpenBand / M.C.Dean
I exposed the menu path and
I exposed the menu path and when I access it as a normal menu it works. It seems that when accessed from ahah it throws error.
seems to be weird error. If
seems to be weird error. If you try to access nonexistent link, drupal should simply comes back with "Page not found
The requested page could not be found."
If you get an http error, i wonder if it has to do with your system config. Like apache, permission etc? just a wild guess...
This resolved the error for
This resolved the error for me
Thanks for everyones help.
Where did you add this line
Where did you add this line ?
sample ahah module
I know your problem is solved but in case someone comes upon this thread, you may want to see:
http://drupal.org/node/308310
When I submit the form, I
AHAH handling code