Hello, I'm starting to use ajax and the Google API (chart) to create charts.
I use a Generic Handler that I called 'EmployeesCompany.ashx', in it I make a query in the database and return a string in this way;
context.Response.Write(valores.ToString());
The data I get comes to Ajax as a string (in the correct format of the parameter I'm supposed to pass) as follows;
Myquestion:'IsitpossibletoconvertthisstringtoavalidarrayorparameterformyGoogleAPIcalltowork?'becauseofthewayitisnowIgetanerrormessagesaying:'JavaScriptruntimeerror:Notanarray'HomeAjaxFunction:
< script type = "text/javascript" >
google.load("visualization", "1", {
packages: ["corechart"]
});
$(document).ready(function() {
var urlH = "GenericHandler/ColaboradoresEmpresa.ashx";
$.ajax({
url: urlH,
type: "POST",
data: {},
async: true,
success: function(Valores) {
alert(Valores);
var data = google.visualization.arrayToDataTable(Valores);
var options = {
title: '',
is3D: false
};
var chart = new google.visualization.PieChart(document.getElementById('Empresa'));
chart.draw(data, options);
},
error: function(data) {
alert("ERRO: " + data.status);
},
timeout: 15000
});
}); < /script>