Calling action method in MVC with jQuery and parameters not working

前端 未结 2 1252
一向
一向 2021-02-10 23:02

I\'m trying to call an action method in an MVC application using jQuery. Basically what I want is to take the value of a couple of input fields and call the action method by cli

相关标签:
2条回答
  • 2021-02-10 23:10

    I usually use the jQuery second parameter of the $.get method to enter the URL parameters. Here is a post (asp.net mvc 1 but still a valid example):

    http://blog.bobcravens.com/2009/11/ajax-calls-to-asp-net-mvc-action-methods-using-jquery/

    0 讨论(0)
  • 2021-02-10 23:29

    Try like this:

    var number = $('#selectWeekId').val();
    var year = $('#selectYearId').val();
    var url = '<%: Url.Action("Edit") %>';
    $.get(url, { number: number, year: year }, function (data) {
        alert('Test');
    });
    
    0 讨论(0)
提交回复
热议问题