Skip to content

Data value get Null in ajax action

Sagar Bandkar

Asked Jan 20, 2017, 12:05 AM EST1 answer
Share
LinkedInX
function GetStatusDetails(id) {
$.ajax({
url: '@Url.Action("GetStatusDetails","GenerateMemo")',
type: "GET",
data: { "id": id },
datatype: "json",
contentType: "application/json; charset=utf-8",
C#
            success: function (data) {
alert(data.vcMemSubject);<-------------------------get Null
                if (data != null) {
                    $("#signature").val(data.vcMemSigunature);
                    $("#subject").val(data.vcMemSubject);
                    $("#body").val(data.vcMemText);
                }
            },
            error: function (e) {
                //alert(e.data);
            }
        });
    }
 
 
 
 
[HttpGet]
Java
        public tblMstMemo_MEM GetStatusDetails(int id)
        {
            try
            {
                if (id > 0)
                {
                    tblMstMemo_MEM statusDetails = db.tblMstMemo_MEM.Find(id);
                    return statusDetails;
                }
            }
            catch (Exception ex) { ex.Message.ToString(); }
            return null;
        }
 

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
     i Got the Solution
     
    in controller i use JsonResult instead of  tblMstMemo_MEM in controller 
    and return Json(statusDetails,JsonRequestBehavior.AllowGet)
    0