Friday, 31 July 2015

JSON Call in MVC


Controller Function :

public ActionResult getdata(){
    var model = new{value= "Bar"}
    return Json(model, JsonRequestBehavior.AllowGet);
}

View Script

$.ajax({
    type : "GET",
    dataType : "json",
    url : "@Url.action("getdata","Home")",
    success: function(data) {
        alert(data.value);
//Enter code here 
    }
});




No comments:

Post a Comment