Submitting a razor form using JQuery AJAX in MVC6 using the built-in functionality

后端 未结 3 1918
无人共我
无人共我 2020-12-22 19:49

I would like to know if there is a specific way to submit a form using jQuery AJAX in MVC6, still using the Auto Binding features of ASP.NET MVC. I believe in other versions

3条回答
  •  鱼传尺愫
    2020-12-22 20:18

    https://github.com/Behrouz-Goudarzi/AjaxTagHelper

    AjaxTagHelper

    A simple solution to using links and ajax forms using Tag Helper in aspnet core

    First, copy the AjaxTagHelper class from the Extensions folder to your project.

    Second, copy the AjaxTagHelper.js file from js folder in wwwroot and add it to your project.

    Then do the following: Open the viewImports file and add the following code

    @using AjaxTagHelper.Extensions
    @using AjaxTagHelper
    @using AjaxTagHelper.Models
    @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
    @addTagHelper *, AjaxTagHelper
    

    To use Action Ajax, add the following code instead of the tag.

      
            Delete
        
    

    Use the following code to use AJAX to send the form to server.

    Create

    Finally, add the scripts you need to view it, check the code below

    
    
    

提交回复
热议问题