I am able to pass my Model to the view with the following Code in controller
Models.Models.AELeadInfo lead = new Models.Models.AELeadInfo();
lead.firstName = "name";
lead.lastName = "lastname";
lead.add1 = "add1";
lead.add2 = "add2";
lead.city = "city";
lead.state = "state";
lead.zip = "zip";
lead.birthDay = "bday";
lead.phone = "phone";
lead.email = "email";
lead.preferedContact = "prefContact";
//do DB stuff
// return model
return Json(lead, JsonRequestBehavior.AllowGet);
My Jquery:
$.ajax({
datatype: "json",
url: "/Home/loadLeadInfo/",
type: 'GET',
contentType: 'application/json; charset=utf-8',
data: { 'leadPhone': lph},
success: function (data) {
$("#ld1_lastName").val( data.LastName);
alert(data.LastName);
},
});
I can see that everything is there when I hover over data in Chrome dev tools, but data.lastName returns undefined. I must be missing something simple here, been trying things and googling for hours with no luck.
data.lastName