Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hook_menu(){
- $items['fetch_info'] = array(
- 'page callback' => 'fetch_info_ajax',
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
- );
- return $items;
- }
- function fetch_info_ajax(){
- echo drupal_render(drupal_get_form('example_form'));
- }
- function example_form($form, $form_states){
- $form['table'] = array(
- '#header' => $header,
- '#rows' => $rows,
- '#theme' => 'table',
- '#sticky' => False,
- '#prefix'=>'<div class="col-xs-12 col-sm-12 no-padding">',
- '#suffix'=>'</div>'
- );
- $form['submit']= array(
- '#type' => 'submit',
- '#value' => t('Download'),
- '#attributes' => array('class'=>array('pull-right')),
- '#submit' => array('cp_submit'),
- '#weight'=> 38,
- );
- return $form;
- }
- function example_form_submit(&$form, &$form_state){
- var_dump($form_state['values']);
- var_dump($form);
- die();
- }
- jQuery.ajax({
- method: "POST",
- url: "/fetch_info",
- dataType: 'html',
- beforeSend:function(){
- },
- success:function(data) {
- if(data != ''){
- jQuery("div .panel-body .output-wrapper").html(data);
- }
- },
- complete:function(){
- Drupal.attachBehaviors();
- }
- });
Add Comment
Please, Sign In to add comment