MVC Ajax Submit Form


/ Published in: C#
Save to your folder(s)

How to submit a form asynchronously and get result in JSON


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.