-1

I have an handsontable and i am trying to read the array data in ASP.Net. i have the below code. When i send the data to server. i keep getting ParseError. I tried different ways but did not help.

var data = [
          ["Year", "Kia", "Nissan", "Toyota", "Honda"],
          ["2008", 10, 11, 12, 13],
          ["2009", 20, 11, 14, 13],
          ["2010", 30, 15, 12, 13]
        ];


var $container = $("#example1");
        $container.handsontable({
            data: data
        });

function sendData() {
        var $container = $("#example1");
        var handsontable = $container.data('handsontable');
        var myData = handsontable.getData();


        $.ajax({
            type: "POST",
            url: "Test.aspx/SaveUser",

            data: "{'data':" + JSON.stringify(myData) + "}",

            dataType: "json",
            success: function (response) {
                alert("Data sent to server.");
                window.location.reload();
            },
            error: function (xhr, status) {
                alert("An error occurred: " + status);
            }
        });
    }

Server side code

<WebMethod()> <ScriptMethod()> _
    Public Shared Sub SaveUser(data As List(Of String))
        Dim lstItems As List(Of Object) = New JavaScriptSerializer().ConvertToType(Of List(Of Object))(data)
    End Sub

Please help me in reading the data and thanks in advance

SSK
  • 783
  • 3
  • 18
  • 42

1 Answers1

0

I figured it out. Hope it helps others

just changed the line

data: '{data: ' + JSON.stringify(myData) + '}',
SSK
  • 783
  • 3
  • 18
  • 42