>Has anyone messed with GoogleCharts and Ajax?
>
>I've got a stored proc (SQL 2008 R2) that I'm calling via Ajax
>
>
> var AjaxData = $.ajax({
> type: "POST",
> contentType: "application/json;",
> url: "WebForm1.aspx/GetHeartBeatData",
> data: "{}",
> dataType: "string",
> async: false
> }).responseText;
> var MyArray = eval("[" + AjaxData + "]");
>
>
>The call to the Stored Proc is returning the data as a string, just like I expect it to be.
>
>The last line should be making an array of the string of data that's coming back. Said data is "Object, (Array)"
>When I look at the MyArray[0] element I see a _proto_ element and a "d" element which actually contains my data.
>
>Name Value Type
>
>MyArray [[object Object]] Object, (Array)
> [0] {...} Object
> _proto_ {...} Object
> d "[Time","DB1"].... String
>
>
>
>
>Then I issue the call for googlechart data acquisition:
>
> var data = google.visualization.arrayToDataTable(MyArray[0]);
>
>
>I get "Not an array" - what the huh?
What's the eval() doing there ? Since you're converting the response to a string then JSON.Parse(AjaxData) would seem to make more sense ?
Also you are specifying a dataType : string which I didn't think exists - I certainly don't see it in the documentation. A valid dataType will override the contentType: application/json - don't know whether 'string' would.
What comes over the wire from the server ? Why not drop the dataType and just get the json response which will automatically be parsed.