i have developed a web application using mvc4.i need to pass some <IList> from controller to view as json result.
below is the code in controller class
public ActionResult GetTradeUserData([DataSourceRequest] DataSourceRequest request, int test)
{
wholeSaleModelUser = new WholeSaleInfoService().PopulateWholeSaleUserData(test);
return Json(wholeSaleModelUser, JsonRequestBehavior.AllowGet);
}
and here is the code of view class
<script>
$("#submitMarketUser").click(function () {
$.ajax({
url: "WholeSaleTrade/GetTradeUserData",
data: { test: $("#Names").val() },
dataType: "json",
type: "POST",
success: function (data) {
alert(data.EmpNm);
$("#Contact").val(data.Contact);
$("#EPFNo").val(data.EPFNo);
$("#TitlKy").val(data.TitlKy);
$("#EmpNm").val(data.EmpNm);
$("#NameInInitials").val(data.NameInInitials);
$("#DtBirth").val(dateFromStringWithTime(data.DtBirth));
},
error: function (e) {
return false;
}
});
});
my problem is data object not getting any data and alert popup with a text as "undefined".
can somebody please help me here.
alert(JSON.stringify(data));show in your success callback?return Json(wholeSaleModelUser, JsonRequestBehavior.AllowGet);in here wholeSaleModelUser get the values as code hit