Ajax reload of block on an event I have created a block through custom module. The content of the block should be random every time it loads the block. Call back function for this was written. The block also has a link say "Next" and when clicked on should reload the block with next random content. 

How to get the block to reload without reloading the whole page when the link Next is clicked on?

Below is the module code I am using and js file.

/*
 * Implement hook_menu
 */

function my_module_menu(){
    $items['tips/reload']=array(
        'title' =&gt; 'Block Reload',
        'page callback'=&gt;'reload_tip',
        'access callback' =&gt; TRUE,
        'type' =&gt; MENU_CALLBACK,
    );
    return $items;
}

/*
 * Implement hook_block_info().
 */
 function my_module_block_info(){
    $blocks['my_module']=array(
        'info' =&gt; t('My Tips'),
        'status' =&gt; TRUE,
        'region' =&gt; 'content',
        'weight' =&gt; 0,
        'visibility' =&gt; 0,
    );
    return $blocks;
 }



 /*
  * Implement hook_block_view().
  */
 function my_module_block_view($delta=''){
    switch($delta){
        case 'my_module':
            $block['subject'] = t('Teamie Tips');
            $block['content'] = my_module_block_content($delta);
            return $block;
        }

 }

 /*
  * tips block content function
  */
 function my_module_block_content($delta){
    $output = "&lt;div id='divTip'&gt;".getrandomtip()."&lt;/div&gt;";
    $output .="&lt;a id='NextTipLink' href='tips/reload'&gt;Next&lt;/a&gt;";
    return array('#markup'=&gt;$output);
 }

  function reload_tip(){
    $tip = getrandomtip();

    return drupal_json_output(array('nexttip'=&gt;$tip));
    exit;
 }

 function my_module_theme(){
    return array(
        'my_module_javascript'=&gt;array('arguments'=&gt;array(),),
    );
 }

 function my_module_init(){
    theme('my_module_javascript');
 }

 function theme_my_module_javascript(){
    $jsfile = drupal_get_path('module','my_module').'/my_module.js';
    drupal_add_js($jsfile);
 }


and my js file is as below

 (function ($) {Drupal.behaviors.my_module = function (context){
    $('a#NextTipLink').click(function(){
        var nextTip = function(data){
            $("#divTip").html(data.nexttip);
        }
        $.ajax({
            type:'POST',
            url:this.href,
            success:nextTip,
            data: 'js=1',
        });
        return false;
    });

}})(jQuery);


When I click on next link, pop up is coming with file having json object. But I need to reload the blok content. Am I doing something wrong?
To answer my own question below is the correct js file that is working.

(attach:function ($) {Drupal.behaviors.my_module = {function (context){
    $('a#NextTipLink').click(function(){
        var nextTip = function(data){
            $("#divTip").html(data.nexttip);
        }
        $.ajax({
            type:'POST',
            url:this.href,
            success:nextTip,
            data: 'js=1',
            dataType:'json',
        });
        return false;
    });

}};})(jQuery);