Today's Deals (in Amazon.com)

 Question:

7 - Ajax callback is not invoked
  • Rashmi

    I am using Drupal 7, and I used hook_form_alter() to add the following markup.

      $form['linkb'] = array(
        '#type' => 'markup',
        '#markup'=>"<a href=''>Click here </a>",
        '#title' => t('something'),
        '#name' => 'linkb',
        '#ajax' => array(
          'method' => 'html', // this is important without this if else condition for ajax will not work.
          'effect' => 'fade',
          'callback' => 'clicktell_verification',
          'wrapper' => 'replace_textfield_div',
        ),
      );
    

    I want to run AJAX when I click on Click here, but this is not working. I have also created a callback function, but it doesn't still work.

    Why isn't the AJAX callback being called?

  •  Answers:

  • kiamlaluno

    #ajax is never used by elements of markup type. You need to use it with one of the following elements:

    • button
    • checkbox
    • checkboxes
    • image button
    • password
    • radio
    • radios
    • select
    • submit
    • tableselect
    • textarea
    • text_format
    • textfield