Having a little trouble with MVC model binding via AJAX.
Can someone tell me why the CreateTransfereeDetails property is not binding, it always comes back as 'null'.
Model:
public class ResolveProfileSelectionRequiredModel
{
public CreateTransfereeModel CreateTransfereeDetails { get; set; }
public bool NewTransfereeSelected { get; set; }
}
public class CreateTransfereeModel
{
[Display(Name = "Transferee Name:")]
public string TransfereeName { get; set; }
}
Html:
<input type="text" id="TransfereeName" />
<input type="hidden" id="NewTrasnfereeSelected" />
JavaScript:
var createTransfereeDetails =
{
"TransfereeName": $("#TransfereeName").val()
};
$.ajax({
url: "/myurl",
dataType: "json",
traditional: true,
type: "POST",
data: {
CreateTransfereeDetails: createTransfereeDetails,
NewTransfereeSelected: $("#NewTransfereeSelected").val()
},
success: function (result) {
//
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
//
},
complete: function () {
//
}
});
Thanks!