I create an ajax link with an image inside this, here my code

function fbf_block_view($delta = ''){
    drupal_add_library('system', 'drupal.ajax');
    $block = array();
    switch ($delta){
        case 'FbF':
            $nodes = entity_load('node', FALSE, array('type' => '4x4'));
            $cont = 0;
            $html = "<div id = 'four'>";
            foreach ($nodes as $node){
                $dir = file_create_url($node->field_image_4x4['und'][0]['uri']);
                $html .= "<div id ='div$node->nid'>".l('<img src="'.  render($dir).'"/>','fbf/'/*.$node->nid.'/nojs'*/,array(
                    'attributes' => array(
                        'id' => "img".$node->nid,
                        'class' => array('use-ajax')
                    ),
                    'html' =>TRUE
                )).'</div>';
            }
            $html .= '</div>';
            $block['content'] = $html;
    }
    return $block;
}

and this is the menu registration

function fbf_menu(){
    $items['fbf'] = array(
        '#page callback' => 'fbf_callback',
        '#access callback' => array('user_access'),
        '#access arguments' => 'access content',
        '#type' => MENU_CALLBACK
    );
    return $items;
}

function fbf_callback($type = 'ajax'){
    if($type == 'ajax'){
        $output = '<div>algo</div>';
        $commands = array();
        $commands[] = ajax_command_replace('#four', $output);
        $page = array(
            '#type' => 'ajax',
            '#commands' => $commands
        );
        ajax_deliver($page);
    }  else {
        $output = t("Contenido devuelto al cargar la página sin Ajax.");
        return $output;
    }
}

It gives me the error: An Ajax HTTP error ocured. HTTP Result code: 403. Permission denied

Comments

nevets’s picture

What if you use 'fbf' (no slash on the end).

imranweb’s picture

Kindly check the permission of the AJAX URL.
Debug the output using Firebug.

-Imran

Crackall’s picture

How can I check that permission

chandan chaudhary’s picture

 $items['fbf'] = array(
        '#page callback' => 'fbf_callback',
        '#access callback' => 'user_access',
        '#access arguments' =>array( 'access content'),
        '#type' => MENU_CALLBACK
    );

try this and check

Need Drupal help?
Reach me

Acquia Certified Developer

Backend Frontend and DevOps.

Crackall’s picture

Nothing