jSon + jQuery Help
Hi,
I want to add Json to my module.
I give a list of letters and want that click on a letter will produce list of nodes beginning with this letter.
2 Questions:
1.
Does anybody know a good guide for using json? I tried to follow the example from the "Pro-Drupal" book, but It's not working yet.
2.
I have 2 questions on my code:
function Mymodule_menu($may_cache){
$items = array();
if($may_cache){
$items[] = array(
'path' => 'letters_page/letter',
'callback' =>'Mymodule_letter_link',
'type' =>'MENU_CALLBACK',
);
}
return $items;
}
a.
In the declaration of the function that the ajax will call (here named 'Mymodule_letter_link'), what should be its type?( I want the function to be called just on clicking a letter and not when the page is loaded from clicking the menu-tab.
b.
what should be the path in the above declaration,
is it the page path the ajax called from or the path the ajax function is written in? is it the same path?
Thank you!
Maybe a good guide or example will help me the best...

try it <?php //...function
try it
<?php
//...
function Mymodule_letter_link() {
$data['someparam'] = 'somevalue';
print drupal_to_js($data);
exit;
}
?>
easy! :)
cya
--
Pedro Faria de Mirando Pinto
http://www.phpavancado.net - DevBlog (pt_BR)
http://www.eusouopedro.com - Blog (pt_BR)
irc://irc.freenode.org/drupal-br - IRC Help channel (pt_BR)
Even easier in D6
When you update to Drupal 6, change the code to ..
<?phpfunction Mymodule_letter_link() {
$data['someparam'] = 'somevalue';
drupal_json($data);
}
?>
Alan Davison
www.caignwebs.com.au