Ajax调用控制器无法正常工作

时间:2015-02-12 09:00:11

标签: javascript ajax asp.net-mvc-4

我正在对C#函数进行ajax调用,但它没有被调用。 ' frmListOfUsersOfflinePartial'是我的表格名称。如果我在ajax调用后删除return false语句,它将转到主页,而不是命中该函数

查看:

@using (@Html.BeginForm("ListOfUsersOffline", "Admin", new { operation = operation, userid = userid ,roleId = roleId}, FormMethod.Post, new { id = "frmListOfUsersOfflinePartial" }))
{

  @Html.ActionLink("Search", "", "", null, new { id = "lnkChooseRegOfficeName", @class = "btn btn-primary" })
}

<script type="text/javascript">
   $("#lnkChooseRegOfficeName").click(function (e)
   {
      var url = '@Url.Content("~/")' + "Admin/RegistrationOfficeNameForUsers";      
      $.ajax({
        url: url,
        type: 'Get',
        data: $('#frmListOfUsersOfflinePartial').serialize(),
        success: function (data) {
            alert(url);
        }
    });
    return false;         
}); 
</script>

控制器:

[HttpGet]
    public ActionResult RegistrationOfficeNameForUsers(ListOfUsers listOfUsers, string operation, int userid)
    {
            //Not getting hit
    }

0 个答案:

没有答案