简体   繁体   中英

RedirectToAction not working in IE with jQuery

I have a problem with the RedirectToAction method.

I call the DeleteTalent action from my jQuery code and DeleteTalent calls RedirectToAction("MyBooks") action after deleting a talent to show refreshed content.

This works fine in Chrome and Firefox, but MyBooks action is not called in Internet Explorer. Can anyone tell me why.

Thank you.

`<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());
    }
    });
});

`

It looks like you are using an AJAX POST to call your controller/action.

RedirectToAction will not work when you use an AJAX post. I found this out when trying to do the same in JQuery Mobile which uses AJAX post.

RedirectToAction not working

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM