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.

<?php
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' => '<div id="replace_div">',
   
'#suffix' => '</div>',
  );
  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.

I will soon be leaving the Drupal forums permanently. To understand why, please see this thread.

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.

najubudeen

Jaypan’s picture

More specifics please.

I will soon be leaving the Drupal forums permanently. To understand why, please see this thread.