开发者

Will the Sharp Architecture ModelBinder properly constitute an object using a jQuery ajax request?

开发者 https://www.devze.com 2023-01-11 04:54 出处:网络
Do you know if it\'s possible to make an AJAX request and have the model binder properly constitute an object based on the parameter provided?

Do you know if it's possible to make an AJAX request and have the model binder properly constitute an object based on the parameter provided?

For example:

$.ajax({
    开发者_如何学Gotype: 'POST',
    url: '../Create',
    data: ( {
        'SkillTypeRequest.Id':                0,
        'SkillTypeRequest.Event.Id':        eventId,
        'SkillTypeRequest.SkillType.Id':    skillTypeId,
        'SkillTypeRequest.Division.Id':     divisionId
    } ),
    success: function (data) { addSkillTypeRow( data ); }
});

The test controller action is:

public ActionResult Create(SkillTypeRequest request) { return Json( request ); }

At the moment, this fails in the model binder because it's trying to assign null to the SkillTypeRequest.Id. Before I investigate further, just want to make sure this is even possible to begin with or does Sharp/MVC only allow this type of binding through forms?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号