1

I get Ajax error when I click next button. You can test it here.

I have found out the problem. It is due to the custom module which I have made.

<!DOCTYPE html>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<?php

/**
 * Implements hook_block_info().
 *
 * This hook declares what blocks are provided by the module.
 */
function custom_module_block_info()
{
    $blocks['tag_cloud'] = array(
        // The name that will appear in the block list.
        'info' => t('Custom Moudle'),
        // Default setting.
        'cache' => DRUPAL_CACHE_PER_ROLE
    );
    return $blocks;
}

When I remove the first two line (Doctype and meta). It works fine. But If I remove first two lines. It doesn't work on IE. I had to insert these two statements to get it working on IE. Now If I keep these two lines, it causes Ajax error, and if not It doesn't work on IE.

Can anyone help?

  • Probably an echo in your code is creating the problem. Please check if there is any unnecessary echo – Nabil Mar 4 '14 at 12:10
2

You can't just add arbitrary HTML at the top of a module file - Drupal runs through a process to theme the page, and you need hook into that.

You have a couple of options:

  1. Override html.tpl.php in your theme, and add the tag to the <head> section manually. This is probably the easiest way.
  2. Use drupal_add_html_head() in your module, e.g.

    $tag = $element = array(
      '#tag' => 'meta', 
      '#attributes' => array(
        'http-equiv' => 'X-UA-Compatible',
        'content' => 'IE=edge',
      ),
    );
    drupal_add_html_head($tag, 'mymodule:ua_compatibility');
    

Make sure you pick an appropriate hook to do this in (preprocess_page, etc), don't just add it to the top of the file or it won't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.