json 개체에 asp.net mvc 컨트롤러 동작으로 전달 중입니다. 두 매개 변수는 모두 널입니다.여러 Json 개체가 HttpPost에서 asp.net mvc 컨트롤러 동작에 바인딩되지 않습니다.
누군가가 실수로 잘못 명명 한 오류를 발견 할 수 있습니까?
/* Source Unit */
var sourceParent = sourceNode.getParent();
var sourceUnitParentId = sourceParent == null ? null : sourceParent.data.key;
var sourceUnit = { unitId: sourceNode.data.key, parentId: sourceUnitParentId };
var sourceUnitJson = JSON.stringify(sourceUnit);
/* Target Unit */
var targetParent = targetNode.getParent();
var targetUnitParentId = targetParent == null ? null : targetParent.data.key;
var targetUnit = { unitId: targetNode.data.key, parentId: targetUnitParentId };
var targetUnitJson = JSON.stringify(targetUnit);
moveUnit(sourceUnitJson, targetUnitJson);
function moveUnit(sourceUnit, targetUnit) {
$.ajax({
url: '@Url.Action("Move", "Unit")',
type: 'POST',
data: { sourceUnit: sourceUnit, targetUnit: targetUnit },
success: function (response) {
},
error: function (e) {
}
});
}
[HttpPost]
public ActionResult Move(DragDropUnitViewModel sourceUnit, DragDropUnitViewModel targetUnit)
{
Unit sUnit = Mapper.Map<DragDropUnitViewModel, Unit>(sourceUnit);
Unit tUnit = Mapper.Map<DragDropUnitViewModel, Unit>(targetUnit);
_unitService.MoveUnit(sUnit, tUnit);
return new EmptyResult();
}
나는 node라는 라벨이 붙은 것을보고 dom 요소라고 가정합니다. 아마 돔이 준비되기 전에 그걸 잡을거야? – MushinNoShin
@MushinNoShin 노드 물건은 jquery dynatree 플러그인에 있습니다. 여기서는 아무런 역할을하지 않습니다. 그것은 MVC 컨트롤러의 동작에 여러 json 객체를 전달하는 것입니다. – Elisabeth