Hi, i am trying to call a custom template file from module into a div tag using ajax. everything is correct but ajax callback function doesn't call the template file from module. i have written my code below. Please help sombody to fix this problem. i hope somebody will help me.

function ajax_temp_menu(){
	$items['ajax_page'] = array(
		'title' => 'soma ajax title',
		'page callback' => 'drupal_get_form',
		'page arguments' => array('ajax_temp_ajax_form'),
		'access callback' => TRUE,
		'type' => MENU_NORMAL_ITEM,
	);
	return $items;
}	

function ajax_temp_ajax_form($form, &$form_state) {
  $form = array();
  
  $form['changethis'] = array(
    '#type' => 'select',
    '#options' => array(
      'one' => 'one',
      'two' => 'two',
      'three' => 'three',
    ),
    '#ajax' => array(
      'callback' => 'ajax_temp_ajax_callback',
      'wrapper' => 'replace_div',
     ),
  );
  $form['html_div'] = array(
    '#type' => 'markup',
    '#prefix' => '
', '#suffix' => '
', ); return $form; } function ajax_temp_ajax_callback($form, $form_state) { return theme('ajax_temp_ajax_output', array()); } function ajax_temp_theme() { return array( 'ajax_temp_ajax_output' => array( 'variables' => array(), 'template' => 'ajax_temp-page', ), ); }

Comments

Jaypan’s picture

First, tell us what you are trying to do, as there are a few problems with how you are trying to do it.


The Drupal organization has shut down discussion on improvement of the forums: https://www.drupal.org/node/2536122

It's time to start a new forum somewhere else. The Drupal organization does not care about the forums.


najubudeen’s picture

I am trying to get dropdown field selected value in a seperate template file and print through ajax. that's why i am trying to do it.

Jaypan’s picture

More specifics please.


The Drupal organization has shut down discussion on improvement of the forums: https://www.drupal.org/node/2536122

It's time to start a new forum somewhere else. The Drupal organization does not care about the forums.