rabid_zombie
rabid_zombie

Reputation: 992

Get data from controller

In my controller:

public ActionResult ViewPage()
{
    Obj object = new Obj();
    object.id = 3;
    var JsonItem = Model.getItem(object);

    return Json(JsonRfc, JsonRequestBehavior.AllowGet);
}

Client-side

$(document).ready(function () {
    $.getJSON({
        url: 'ViewPage',
        function(data) {
            console.log(data);
        }
    });
});

I'm not logging anything in my console (console.log(data) returns nothing). What am I missing here? When I click on the ActionLink ViewPage, it should go into the model and do some stuff. After I want to get it from the client-side to generate a list view.

Upvotes: 0

Views: 296

Answers (1)

Jordan
Jordan

Reputation: 2758

Perhaps you are missing something. Try

$(document).ready(function () {
    $.getJSON({
        url: 'ViewPage',
        success: function(data) {
            console.log(data);
        }
    });
});

Upvotes: 1

Related Questions