Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
_proto_ and JSON
Message
From
17/07/2014 15:18:12
 
 
To
All
General information
Forum:
Javascript
Category:
Coding, syntax & commands
Title:
_proto_ and JSON
Miscellaneous
Thread ID:
01603953
Message ID:
01603953
Views:
48
Again, calling an SP that should be returning an array of data points, ie

[["DB1", 2],["DB2,4],...["COM",10]]

via an Ajax call, fed into a variable "DataArray" which is then fed into GoogleCharts.

Here's the code:
        google.load("visualization", "1", { packages: ["corechart"] });
        google.setOnLoadCallback(drawChart);

        function drawChart() {
            var AjaxData = $.ajax({
                type: "POST",
                contentType: "application/json;",
                url: "WebForm1.aspx/GetHeartBeatData",
                 dataType: "json",
                async: false
              }).responseText;
     
            var MyArray = JSON.parse(AjaxData);
            var DataArray = JSON.parse(MyArray.d);
            var data = google.visualization.arrayToDataTable(DataArray);
Here's what I get:
		AjaxData	"{"d":"[{\"time\":1,\"db1\":1,\"db2\":2,\"db3\":3,\"db4\":4,\"db5\":5,\"db6\":6,\"db7\":7,\"db8\":8,\"comm\":9},{\"time\":2,\"db1\":4,\"db2\":5,\"db3\":6,\"db4\":7,\"db5\":8,\"db6\":6,\"db7\":4,\"db8\":2,\"comm\":1},{\"time\":3,\"db1\":9,\"db2\":8,\"db3\":7,\"db4\":3,\"db5\":2,\"db6\":1,\"db7\":1,\"db8\":2,\"comm\":3}]"}"	String

-		MyArray	{...}	Object
+		__proto__	{...}	Object
		d	"[{"time":1,"db1":1,"db2":2,"db3":3,"db4":4,"db5":5,"db6":6,"db7":7,"db8":8,"comm":9},{"time":2,"db1":4,"db2":5,"db3":6,"db4":7,"db5":8,"db6":6,"db7":4,"db8":2,"comm":1},{"time":3,"db1":9,"db2":8,"db3":7,"db4":3,"db5":2,"db6":1,"db7":1,"db8":2,"comm":3}]"	String

-		[0]	{...}	Object
+		__proto__	{...}	Object
		comm	9	Number
		db1	1	Number
		db2	2	Number
		db3	3	Number
		db4	4	Number
		db5	5	Number
		db6	6	Number
		db7	7	Number
		db8	8	Number
		time	1	Number
I pass DataArray to GoogleCharts and I get either "Not an array" or Invalid row type for row 0. Apparently, the '_proto_' is the issue. Please don't tell me that what I'm doing should work. It doesn't.



I'm REALLY getting tired of beating my head against this brick wall.
"You don't manage people. You manage things - people you lead" Adm. Grace Hopper
Pflugerville, between a Rock and a Weird Place
Next
Reply
Map
View

Click here to load this message in the networking platform