Tyfius
Legacy Member
Ik heb onderstaande vraag ook gesteld op de Drupal.org support mailing list, maar voor alle zekerheid zal ik ze hier ook eens stellen:
Ik ben niet echt een expert in JavaScript/jQuery/JSON/Ajax dus alle hulp is meer dan welkom.
Wat ik dus zou moeten bereiken is een pagina die elke X seconden ververst en waar ik via een aantal check boxen de lijst met online servers die worden weergegeven kan aanpassen zonder effectief een form te submitten.I am developing a module (Drupal 6.4) which shows a list of online
servers. The list is refreshed each X seconds. I used the book "Learning
Drupal 6 Module Development" and inside I found the perfect trick. I
created an empty page which contains 2 blocks.
Block A: contains the server list and using JSON/jQuery it gets
refreshed each X seconds.
Block B: contains a form with 3 check boxes.
So far I am only using block A and everything works as expected. The
server list is shown and gets refreshed each X seconds. The goal is to
allow the check boxes in Block B to control which type of online servers
are listed. For this I needed something like on-toggle -> set variable.
I don't want to use any real submit form stuff but the status the check
box should change and I should be able to perform a variable_set().
Thanks to someone on the Drupal IRC channels I got the following piece
of code:
Code:$('input[@type=checkbox]').click(function() { $.ajax({ type:'POST', data:{val:$(this).attr('checked')}, url: 'path_to_a_drupal_menu_item', dataType: "json", success:function(json) { alert(json.result); } }); });
I am not sure however how this works. I assume I need to put it in my
module's .js file and it will call the 'path_to_drupal_menu_item' but
how is the result processed? Is it passed as an argument and can I fetch
it and perform a variable_set() or does it simply update the page itself
and changes the html element 'checked' of the check box?
Any help and/or pointers towards a correct solution are greatly appreciated.
Ik ben niet echt een expert in JavaScript/jQuery/JSON/Ajax dus alle hulp is meer dan welkom.