How to create a method in the Controller so that it becomes AJAX Callable?
For example, code {0} can be accessed using {1} when the return type is ActionResult:
{0}:
public ActionResult TestWithActionResult(string id)
{
return View();
}
{1}:
http://localhost:4574/ControllerName/TestWithActionResult/2
but my below code {3} can’t be accessed with {4}:
{3}:
public string TestWithString(string id)
{
return "some string";
}
{4}:
http://localhost:4574/ControllerName/TestWithString/2
the id in the {3} is always null when I open {4}.
Should I decorate {3} differently? How?
Thanks,
Try using a JsonResult:
Edit:
You can call the function using AJAX like this (using Jquery)