[development] how to right AJAX enabled module?
Ahmad Al-Obaidy
ahmad at hitech-iraq.com
Mon Jul 16 08:34:30 UTC 2007
Hello Amr,
Thank you man,
I got it work with with with node service... its more than enough for me!
everything works ok on Firefox... but with IE ... it just not working
my script look like this:
function avl_get_location() {
Drupal.service('node.load',
{nid: avl_nid, fields: ["nid", "title"]},
function(status, data) {
alert(data.title);
}
);
}
** status is always false!
I dont know if it is some bug...
but I will make some checks ... and I will report it here
Amr Mostafa <amr.mostafa at gmail.com> wrote: Hello Ahmed,
In Drupal5 I do this by creating a menu item of the type
MENU_CALLBACK, with a callback e.g. mymodule_get_rank_json() which
goes like:
function mymodule_get_rank_json() {
// ...
// The code to determine rank and put it in $rank.
// ...
// This is how to JSON-ify the returned value
header('Content-type: text/javascript');
print drupal_to_js($rank);
}
drupal_to_js() converts the given parameter to JSON and then you print
that back to the browser. To capture the returned information using
javascript and do something useful with it, check Ajax documentation
in jQuery library (the library that is included and used by default
within Drupal) http://docs.jquery.com/Ajax
Cheers,
- Amr
On 7/15/07, Ahmad Al-Obaidy wrote:
> Hi,
>
> I need to display a value given in the database.... the value is modified
> regularly by other programs....
>
> the value should be refreshed regularly .... but not the entire page...
>
> I tried JSON ... but didnt find a useful docs..
> from where should i start?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20070716/703775a4/attachment.htm
More information about the development
mailing list