0
我有一個handontable,我想讀取ASP.Net中的數組數據。我有下面的代碼。當我發送數據到服務器。我不斷收到ParseError。我嘗試了不同的方式,但沒有幫助。如何讀取ASP.Net中的Handsontable數組?
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);
}
});
}
服務器端代碼
<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
請幫我在讀提前