我有以下脚本:
obj = [];
obj = [{ AllocationStatus: false,
BRId: 2,
BRName: "rifat",
SupervisorId: 19,
SupervisorName: "Ashraful"
}];
console.log(obj);
var data2send = JSON.stringify(obj);
$.ajax({
type: "POST",
url: "../WebService1.asmx/allocatebr",
data: "{'brlist':'" + data2send + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg.d);
},
error: function () {
alert('error f');
}
});
在网络服务中,我有以下代码:
[WebMethod]
public string allocatebr(List<Allocation> brlist)
{
//foreach(Allocation br in brlist){
//}
return "success";
}
public class Allocation
{
public int SupervisorId { get; set; }
public string SupervisorName { get; set; }
public int BRId { get; set; }
public string BRName { get; set; }
public bool AllocationStatus { get; set; }
}
但我收到错误:加载资源失败:服务器响应状态为 500(内部服务器错误)。我的代码有什么问题?我想将对象列表传递给方法。怎么做?任何人都可以帮助我非常感激。nbi 得到了 obj 数组
`$('.chkgrip').each(function () {
if ($(this).is(':checked')) {
var x = $(this).closest('tr').data('row');
obj.push(x);
}
});`