Monday, July 13, 2015

ASP.NET MVC Call Controller with jQuery $.ajax and Return PartialViewResult

Hi,

Didn't find a one-stop answer to this question, so here it is:

"How do I POST JSON to an ASP.NET MVC controller?"

It's actually quite simple. Follow the following steps.

1. Create a model to represent the data structure you want to POST



2. Create a controller method to represent the endpoint you want to contact



3. Create the following jQuery call to make an AJAX call from the frontend to the backend



You can return a PartialViewResult from the controller, and as long as the jQuery AJAX call expects html it will be done.

Hope this helps someone.

4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. You explained it so perfectly. I was worried to learn this because I stay busy with affordable essay and I thought it would take a lot of time. But I learned it quickly through your post.

    ReplyDelete
  3. You have a lot of knowledge in resolving this issue. You provide interesting information and explanations of how you did it. The attention you pay to blogging makes it popular.

    ReplyDelete
  4. Gotoassignmenthelp is team of leading professional writers for Assignment Help Writing Services to students all around the world. Contact us today for Best Canada Assignment Help at very affordable price. Under GotoAssignmentHelp we provide many types of help to the students. We are the most reliable assignment helpers. We have gained our specialization after spending most of our times in making ourselves perfect. . We providing 100% plagiarism free Assignment Help. At the point when you pick our Assignment Help Experts assistance, our faculty will consider the quality and your evaluation criteria.

    ReplyDelete