RedirectToAction无法在IE中使用jQuery

时间:2012-02-24 11:03:26

标签: c# ajax asp.net-mvc jquery

我的RedirectToAction方法存在问题。

我从jQuery代码和DeleteTalent调用中调用DeleteTalent操作 删除人才以显示刷新内容后的RedirectToAction("MyBooks")操作。

这在Chrome和Firefox中运行良好,但在Internet Explorer中未调用MyBooks操作。任何人都可以告诉我原因。

谢谢。

`<script type="text/javascript">
var controller = "/MyBooks";
var action = 'ModifyTalent';

var temp = [];

$('input[name=Validate]').click(function () 
{

    $('textarea[name=presentation]').each(function () 
    {
        var toPush;
        if ($(this).attr('id') == null) 
        {
            toPush = { MyPresentationId: -1, Presentation: $(this).val() };
        }
        else 
        {
            toPush = { MyPresentationId: $(this).attr('id').split('_')[1], Presentation: $(this).val() };
        }

        temp.push(toPush);
    });

    var presentations = JSON.stringify(temp);
    var talentId = $('[name=talent]').attr('id').split('_')[1];
    var talent = $('[name=talent]').val();
    var datas;

    if ($(this).attr('id') == -1) 
    {
        action = 'CreateTalent';
        datas = 'id=' + $('#IdBook').val() + '&talent=' + talent + '&presentations=' + presentations;
    }
    else 
    {
        datas = 'id=' + talentId + '&talent=' + talent + '&presentations=' + presentations;
    }

    $.ajax({
    url: controller + '/' + action,
    type: 'POST',
    dataType: 'html',
    data: datas,
    success: function (data) {
    $("#bodyPage").html(data.toString());
    }
    });
});

`

1 个答案:

答案 0 :(得分:1)

看起来您正在使用AJAX POST来调用控制器/操作。

使用AJAX帖子时,

RedirectToAction不起作用。我试图在使用AJAX帖子的JQuery Mobile中做同样的事情时发现了这一点。

RedirectToAction not working

相关问题