PageMethods with ASP.Net MVC

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

What is equivalent PageMethods.MyFunction()in MVC where MyFunction is a controller action?

I know that I can use a function Jsonto return a value, but how can I call an action from the client?

+5
source share
2 answers

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

I think you're looking for either getJSON

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

or ajax jQuery method.

JSON ASP.NET MVC .

+7

, . asp.net - .

MVC , XHR url (../controller/action/params - ) JSON .

: , , , XHR . javascript XMLHttpRequest, JS, , , . , jQuery,

+2

All Articles