【发布时间】:2011-01-25 02:04:24
【问题描述】:
我已经遍历了一个简单的收集数据并将其推送到一个数组中。然后我试图将该数组发送到页面方法(.aspx)。数组有一些东西不像我想的那样。这是我的代码:
//packaging table data for submit to server
$("#saveToDB").click(function() {
var dataForSubmit = new Array();
//gather all data to array except the "delete" cell, .rowToDelete
$('#QueueTable tbody td:not(.rowToDelete)').each(function() {
dataForSubmit.push($(this).html());
});
//test the array
//alert(dataForSubmit);
//send array to method
$.ajax({
type: "POST",
url: "DailyReceipts.aspx/saveData",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: dataForSubmit,
success: function(msg) {
$.jGrowl('Your data has been successfully saved.', { header: 'Important' });
$('#result').append(msg.d)
},
error: function() {
$.jGrowl('An error has occured in saving the data.', { header: 'Important' });
}
});
});
【问题讨论】:
-
你有什么错误吗?您的服务器端脚本如何?看来您正在使用 PageMethods。
-
它达到了我的错误处理。服务器端看起来像这样: public void saveData(string[] theData)