Guest User

Untitled

a guest
Nov 14th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. function hook_menu(){
  2. $items['fetch_info'] = array(
  3. 'page callback' => 'fetch_info_ajax',
  4. 'access callback' => TRUE,
  5. 'type' => MENU_CALLBACK,
  6. );
  7. return $items;
  8. }
  9.  
  10. function fetch_info_ajax(){
  11. echo drupal_render(drupal_get_form('example_form'));
  12. }
  13.  
  14. function example_form($form, $form_states){
  15. $form['table'] = array(
  16. '#header' => $header,
  17. '#rows' => $rows,
  18. '#theme' => 'table',
  19. '#sticky' => False,
  20. '#prefix'=>'<div class="col-xs-12 col-sm-12 no-padding">',
  21. '#suffix'=>'</div>'
  22. );
  23.  
  24. $form['submit']= array(
  25. '#type' => 'submit',
  26. '#value' => t('Download'),
  27. '#attributes' => array('class'=>array('pull-right')),
  28. '#submit' => array('cp_submit'),
  29. '#weight'=> 38,
  30. );
  31. return $form;
  32. }
  33.  
  34. function example_form_submit(&$form, &$form_state){
  35. var_dump($form_state['values']);
  36. var_dump($form);
  37. die();
  38. }
  39.  
  40. jQuery.ajax({
  41. method: "POST",
  42. url: "/fetch_info",
  43. dataType: 'html',
  44. beforeSend:function(){
  45. },
  46. success:function(data) {
  47. if(data != ''){
  48. jQuery("div .panel-body .output-wrapper").html(data);
  49. }
  50. },
  51. complete:function(){
  52. Drupal.attachBehaviors();
  53. }
  54. });
Add Comment
Please, Sign In to add comment