As I work on my ASP.Net web application, I am encountering an issue with binding data from a database to a Google Combo chart via a Web Service class.
While I can successfully bind the data to a grid view, attempting to bind it to the chart results in the following error message:
Invalid Json String:
!Doctype HTML
html lang = "en"
This is my first experience working with javascript, so I suspect that my JavaScript methods are not accessing the correct data. Any guidance on where I might be making a mistake would be greatly appreciated.
DEFAULT.ASPX
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
google.load("visualization", "1", { packages: ["corechart"] });
google.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var jsonData = $.ajax({
url: "Default.aspx/GetChartData",
dataType: "json",
async: false
}).responseText;
var data = new google.visualization.DataTable(jsonData);
var options = {
title: 'Chart Title',
vAxis: { title: 'Scores %' },
hAxis: { title: 'Counties' },
seriesType: 'bars',
series: {
2: {
targetAxisIndex: 1
},
vAxes: {
1: {
title: '1',
textStle: { color: 'red' }
}
}
}
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<asp:GridView ID="Grid1D" runat="server"
AutoGenerateColumns = "true" Font-Names = "Arial"
Font-Size = "11pt" AlternatingRowStyle-BackColor = "#C2D69B"
HeaderStyle-BackColor = "green" AllowPaging ="true"
PageSize = "10" Caption = "1-Dimensional Array">
</asp:GridView>
<div id ="chart_div" style="width:500px;height:400px"></div>
<asp:Literal ID="ltScripts" runat="server"></asp:Literal>
</body>
</html>