Posted By

DennisvanderStelt on 06/06/14


Tagged

form ajax submit MVC


Versions (?)

MVC Ajax Submit Form


 / Published in: C#
 

How to submit a form asynchronously and get result in JSON

  1. @section Scripts {
  2. <script type='text/javascript'>
  3. function onSucces(content) {
  4. $("#result").text(content.Result);
  5. }
  6. </script>
  7. }
  8.  
  9. @using (Ajax.BeginForm("Subscribe", "Home", new AjaxOptions() { OnSuccess = "onSucces", LoadingElementId = "loader" }))
  10. {
  11. @Html.TextBoxFor(s => s.EmailAddress);
  12. <input type="submit" value="button" />
  13. <div id="loader" style="display:none">Even wachten!</div>
  14. <div id="result"></div>
  15. }

Report this snippet  

You need to login to post a comment.