PageMethods with ASP.Net MVC

前端 未结 2 1862
情话喂你
情话喂你 2021-01-18 18:45

I have found ASP.Net PageMethods very handy and easy to use, but I have just started developing using MVC and am not sure how to use them?

What is the equivalent of

2条回答
  •  无人共我
    2021-01-18 19:37

    I know I can use the Json function to return a value, but how do I call the action from the client?

    I think you're looking for either getJSON

    $.getJSON("/controller/action", function(json)
    {
      alert("JSON Data: " + json.users[3].name);
    });
    

    or the ajax jQuery method.

    Either can call an action and get JSON data back from ASP.NET MVC very easily.

提交回复
热议问题