3
Answers

MVC Model binding in ajax responce method

Mahesh Patil

Mahesh Patil

9y
577
1
Hello
 
I want to bind MVC  model  in ajax call responce  like
 
$.ajax({
async: false,
url: $('#ajaxURLclockoutDetails').val(),
type: 'GET',
cache: false,
data: {
newServiceCode: Selectedvalue,
'ConsumerServiceAndPeriod.ConsumerID': $('#DConsumerID').val()
},
success: function (result) {
1) $('#ConsumerServiceAndPeriod.TimesheetID').val(result.TimesheetID);
or
2) @Html.HiddenFor(m => m.TimesheetID, new { Value =@<%'$("#DConsumerID").val()'%> })
 or
3)@Html.Hidden("ConsumerServiceAndPeriod.TimesheetID", result.TimesheetID)
 
});
 
i have mention three possible ways for binding model but no any of them worked
so any one can help me about 
bind ConsumerServiceAndPeriod model in ajax responce method
 
Thanks in advance 
 
Answers (3)