小编Ale*_*lex的帖子

从视图AJAX发布后,ASP.NET MVC RedirectToAction不起作用

我试图从控制器重新加载视图,以便在对控制器进行AJAX POST调用后显示存储在TempData中的数据。问题是我对方法RedirectToAction的调用未重定向任何内容。

这是一些代码示例

视图:

    $('#incidentTableBody').on('click', 'button.relayBack', function () {
            Post('/Incident/RelayBack', { incidentId: $(this).parent().parent().data('id'), ownerId: $(this).parent().parent().data('ownerid') }, function () {  });
        });

    function Post(action, data, callback) {
            $.ajax({
                url: action,
                type: "POST",
                data: data,
                //error: function (jqXHR, textStatus, errorThrown) {
                //    console.log(errorThrown);
                //},
                success: callback,
                cache: false
            });
        }
Run Code Online (Sandbox Code Playgroud)

控制器:

    [Authorize]
    public ActionResult IncidentList()
    {
        ViewBag.Title = "IncidentList";
        return View();
    }

    [HttpPost]
    [Authorize]
    public ActionResult RelayBack(string incidentId, string ownerId)
    {
        bool success;
        try
        {
            new Guid(_incidentService.RelayBack(new Guid(incidentId), new Guid(ownerId)));
            success = …
Run Code Online (Sandbox Code Playgroud)

javascript asp.net ajax asp.net-mvc jquery

3
推荐指数
2
解决办法
1697
查看次数

how to add data-attributes to the rows of a JQuery DataTable

I would like to had (multiple) data-attributes to the generated rows of my JQuery DataTable so that I can store data in it.

What I want to achieve is to make DataTables generate something like this:

<tr data-foo="bar">
  <td></td>
</tr>
Run Code Online (Sandbox Code Playgroud)

Is it possible? How to do it? Thanks.

datatable jquery datatables

2
推荐指数
1
解决办法
5345
查看次数

标签 统计

jquery ×2

ajax ×1

asp.net ×1

asp.net-mvc ×1

datatable ×1

datatables ×1

javascript ×1