Below is my html
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.charts.load('current', { 'packages': ['corechart'] });
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var jsonData = $.ajax({
url: "getData.aspx/getdata",
dataType: "html",
async: true
}).responseText;
alert(jsonData);
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(jsonData);
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, { width: 400, height: 240 });
}
</script>
</head>
<body>
<!--Div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>
Below is the getdata code am calling
[WebMethod()]
[System.Web.Script.Services.ScriptMethod()]
public static string getdata() {
JJSG genTool1 = JJSGTool.SetTool;
DataSet ds = genTool1.DataSetData("select regionID,region from static_region");
string result = genTool1.SerializeObj2String(ds.Tables[0]);
try {
return result;
}
catch (Exception ex) {
Panel pnl = new Panel();
MessageBox.Show(pnl, ex.Message);
return result;
}
}
It is alerting undefinded.
I used this code on something else with jquery and it works fine , I dont know why it is not working.
Please assist me.
Thank