Ajax将变量值发送到MVC控制器

时间:2017-09-07 17:55:18

标签: ajax asp.net-mvc

我正在尝试使用ajax调用从jQuery发送一个值并获取控制器中的值。以下是我正在尝试的内容,但A的值始终为null。有人可以在我出错的地方帮助我。

      $.ajax({
                type: "POST",       //The type of Method being used (GET, SET, POST, etc.)
                url: '/Controller1/Index',
                contentType: 'application/json; charset=utf-8',                
                data: { A: "true" },           //Your data to pass to your Controller action
                dataType: "json",
                success: function (result) {
                    alert(response.responseText);                
                    alert("Done!");
                }
            });

C#代码

 [HttpPost]
 [ActionName("Index")]
 public ActionResult IndexPost(FilterRule queryBuilder, BootstrapTableQueryType bootstrapTable, string A)
 {
     string B = A;
 }

0 个答案:

没有答案