I'm beginner with drupal, I use drupal 7.x and I would like to create a simple ajax call.
I have a template file and I have a button in it with a javascript function in onclick method.
<input type='button' onclick='doajax()'>
<div id='ajaxresponsediv'></div>
In the js file:
function doajax()
{
jQuery.get(url,function(data) {
jQuery("#ajaxresponsediv").html(data);
});
}
Ok it's a simple thing. But what do I have to code in .module file ? What will be the url variable in my code? How do I implement the callback function (for example I would like to print simply 'Hello' into ajaxresponsediv ) ? Do I have to register something in mymodule_menu() function? Thanks for the guidelines.