You can call a module function from the jquery ajax function to perform some database related operations based on ajax.
To start, create a menu item using hook_menu
function mymodule_menu() {
$items = array();
// Create a path to send our AJAX request to.
$items['mymodule_ajax'] = array(
'title' => 'menu title',
'page callback' => 'mymodule_ajax_function',
'access arguments' => array('access example ajax'),
'type' => MENU_CALLBACK,
);
return $items;
}
function mymodule_ajax_function(){
// Here you can perform your database operations
$var = "testing";
return drupal_json($var);
}
And then add a js file to your module and paste the following code.
Drupal.behaviors.mymodule=function(context){
//click event
jQuery.ajax({
url: "mymodule_ajax",
type: "POST",
dataType: "json",
success: function(data){
alert(data);
}
});
}
Cheers
To start, create a menu item using hook_menu
function mymodule_menu() {
$items = array();
// Create a path to send our AJAX request to.
$items['mymodule_ajax'] = array(
'title' => 'menu title',
'page callback' => 'mymodule_ajax_function',
'access arguments' => array('access example ajax'),
'type' => MENU_CALLBACK,
);
return $items;
}
function mymodule_ajax_function(){
// Here you can perform your database operations
$var = "testing";
return drupal_json($var);
}
And then add a js file to your module and paste the following code.
Drupal.behaviors.mymodule=function(context){
//click event
jQuery.ajax({
url: "mymodule_ajax",
type: "POST",
dataType: "json",
success: function(data){
alert(data);
}
});
}
Cheers
Isnt it look so kool ?
To do this thing there's a small trick to do in your computer and its so easy, then lets start.
Copy the following to your text editor and save it as desktop.ini in the folder whose background you want to change.
[{BE098140-A513-11D0-A3A4-00C04FD706EC}]
iconarea_image="complete picture location"
iconarea_text=0x00000000 <------- File text color can be set to any value just now its black.
0x00ffffff for white.
Run the following command in the command prompt
attrib +s "path of the folder"
e.g. attrib +s "E:\old download" will change the background of the folder "old download"
It would be good to keep the file desktop.ini hidden.
So right click on it > go to properties and change its atribute to hidden.
Thats it. Just try it and show the kool looks of your computer to your friends.
Isnt it Amazing trick?