MVC jquery ajax call with input parameter

前端 未结 1 1859
没有蜡笔的小新
没有蜡笔的小新 2021-01-15 02:53

I\'m facing a problem when calling an action on a controller with an argument

In the controller i have following action:

[HttpPost]
public ActionResu         


        
1条回答
  •  无人共我
    2021-01-15 03:19

    You have to just remove content type and also better if you pass controller name in URL:

     $.ajax({
            url: '@Url.Action("UpdateData","YourControllerName")',
            dataType: "json",
            type: "POST",            
            cache: false,
            data: {month:'may'} ,
            success: function (data) {
                if (data.success) {
                    alert(data.message);
                }
            },
            error: function (xhr) {
                alert(xhr.responseText);
            }
    });
    

    0 讨论(0)
提交回复
热议问题