I tried the ajax post from my view as shown below (using jQuery).
Complete solution here.
$(document).ready(function () { var kk = { Address1: "423 Judy Road", Address2: "1001", City: "New York", State: "NY", ZipCode: "10301", Country: "USA" }; console.log(JSON.stringify(kk)); $.ajax({ url: 'Check', type: 'POST', data: JSON.stringify(kk), dataType:"json", contentType: 'application/json; charset=utf-8', success: function (data) { alert(data.success); }, error: function () { alert("error"); } }); });
And got it in the controller (the method is always called)
public ActionResult Check(AddressInfo addressInfo) { return Json(new { success = true }); }
The model is here , But when I tried to access (check the breakpoint), the properties of the object ( AddressInfo ) always displayed null . I tried, not pulling and pulling. Now I'm learning MVC and getting started. Please, help
source share