I need help implementing an ajax block to prevent it from being cached by Boost module I have a website fully cached through boost module with a region where a block is displayed. In this block content is shown via views and the display order in the view is set to random. So far so good. This works fine when logged in. But for guest users only the first block content that hits the cache is shown.

I found a snippet on drupalgroups that should do the trick, an "ajaxified block".

This is the snippet for blocka.php

&lt;?php
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$block = module_invoke('statistics', 'block', 'view', 0);
print $block['content'];
?&gt;


And this should go in a block:

&lt;div id="info"&gt;
&lt;/div&gt;
&lt;script&gt;
$('#info').load('/blocka.php');
&lt;/script&gt;


To test this I created the "ablock.php" and put it in the root directory and also made a block with the code.

Firebug tells me that the block is there, but it doesn't show any statistic. 


How can i debug this to find out, if the blocka.php is loaded? 
How do i have to customize this line for my needs? In fact, i do not understand this line...

$block = module_invoke('statistics', 'block', 'view', 0);


Thanks for any advice.
Without comment to the overall approach, but rather to "I do not understand this line," module_invoke() invokes a hook in a specific module with any arguments passed. The snippet you found is for Drupal 6, so that's the major part of the issue here.

$block = module_invoke('statistics', 'block', 'view', 0);


invokes statistics_block('view', 0) which means to view the 0th block of the statistics module, and

print $block['content'];


prints out its contents (so they get loaded into your #info div later on via ajax).

But, there is no hook_block in Drupal 7, it's now hook_block_view (and hook_block_info) so you need something along the lines of...

$block = module_invoke('statistics', 'block_view', 0);


instead to accomplish what you are looking to do.  

More information on all of this can be found here:

http://api.drupal.org/api/drupal/modules!block!block.api.php/function/hook_block_view/7

http://api.drupal.org/api/drupal/modules!block!block.api.php/function/hook_block_info/7

Now, if what you are wanting to do is put the contents of a View in this block, you could do something like this one-liner instead of the module_invoke/print above:

print views_embed_view('NAME_OF_THE_VIEW');


with more information on views_embed_view here:

http://api.drupal.org/api/views/views.module/function/views_embed_view/7