我正在尝试将 Json 数据发送到我的控制器操作。
jQuery
function SaveConnection() {
debugger;
var CardConnection = {
ConnectionDetails: []
};
var allConn = jsPlumb.getAllConnections();
var length = allConn["green dot"].length;
for (var i = 0; i < length; i++) {
CardConnection.ConnectionDetails.push({
"CardIDFrom": allConn["green dot"][i].sourceId,
"CardIDTo": allConn["green dot"][i].targetId
});
}
var CardDetails = $('#CardDetails');
var url = CardDetails.attr('save-data');
$.ajax({
url: url,
data: JSON.stringify(CardConnection),
type: 'POST',
contentType: 'application/json, charset=utf-8',
dataType: 'json'
});
return false;
}
控制器动作
public ActionResult SaveConnections(List<CardConnection> ConnectionList)
{
return Json(ConnectionList);
}
问题是 - 它始终在行动参数中显示为空。