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.

6 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. When faced with a problem it is important not to panic, there is always a way out. Writing an academic paper is not the worst thing and if you can not write your own essay writing service canada https://ca.essaywritingservice.com/ help you with this. Order an original essay, the author will help to cover your topic and you will have the coolest academic paper.

    ReplyDelete
  5. Casino: How to use my ID to log in and play online slots
    To 동해 출장샵 get to the casino, click on 여수 출장샵 the 안성 출장샵 “Register” icon. The 순천 출장안마 next screen appears in the top right corner, and you can click through the registration 의정부 출장안마 and

    ReplyDelete
  6. When faced with a problem it is important not to panic, there is always a way out. Writing an academic paper is not the worst thing and if you can not write your own business assignment writing service you with this. Order an original essay, the author will help to cover your topic and you will have the coolest academic paper.

    ReplyDelete