php - Google chart with ajax call is not working in drupal -


i tring use google chart drupal ajax call not showing me . when checking ajax-url (localhost/drupal/gethello) in browser making graph correctly.

please see code , ajax call -:

    function hello_menu(){     $items = array();     $items['hellopage'] = array(          'title'=>'my hello page',         'description'=>'hello users',         'page callback'=>'drupal_get_form',         'page arguments'=>array('show_hello_form'),         'access callback'=>'user_access',         'access arguments'=>array('access content'),         'type'=>menu_normal_item             );     $items['gethello'] = array(         'page callback'=>'hello_ajaxcallhandler',         'access callback'=>'user_access',         'access arguments'=>array('access content'),         'type'=>menu_callback            );      return $items;   }    /*ajax response*/ function hello_ajaxcallhandler(){     echo "<h2>ajax complete see response -: </h2>".filter_xss($_get['name']).show_charts(); }  /* simple chart generated google api */ function show_charts(){  return <<<eod          <script type="text/javascript" src="https://www.google.com/jsapi"></script>         <script type="text/javascript">           google.load("visualization", "1", {packages:["corechart"]});           google.setonloadcallback(drawchart);           function drawchart() {              var data = google.visualization.arraytodatatable([               ['task', 'hours per day'],               ['work',     11],               ['eat',      2],               ['commute',  2],               ['watch tv', 2],               ['sleep',    7]             ]);              var options = {               title: 'my daily activities'             };              var chart = new google.visualization.piechart(document.getelementbyid('piechart'));              chart.draw(data, options);           }         </script>         </head>         <div id="piechart" style="width: 900px; height: 500px;"></div> eod; 

here ajax call hello.js in ..modules/hello/hello.js

jquery(document).ready(function(){  jquery("#submitajaxbutton").click(function(){      //alert("you clicked on button");     jquery.ajax({         url:drupal.settings.basepath + 'gethello',         data:{             name: jquery("#edit-name").val(),         },         success:function(data){             //ajax return value               //alert(data);             jquery("#msg-display-area").html(data);         }      }); });  }); 


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -