0

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?

1 Answer 1

2

#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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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