1

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

`

user1213375
  • 21
  • 1
  • 5
  • Because your problem is IE specific I would imagine the problem is client side - so an error in your javascript/jQuery. Can you please post your code. – Rory McCrossan Feb 24 '12 at 11:06
  • this code is for EditTalent.ascx.. when you validate, ModifyTalent action is called, its makes changes on database and call MyBooks action to comeback to list of talents.. thank you.. – user1213375 Feb 24 '12 at 11:17
  • You can't "Redirect" AJAX request. Are you sure it works in Chrome and in FF? – gdoron Feb 24 '12 at 11:20
  • yess.. it works like this : i have a a partial page called MyBooks, you can modify a talent for example, when you click on modify talent, editTalent action is called, it display another partial page to modify the selected talent....when you modify and validate...modifyTalent action is called, it modfies on database and calls MyBooks action to comeback.. – user1213375 Feb 24 '12 at 11:27

1 Answers1

1

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

Community
  • 1
  • 1
Mamayo
  • 41
  • 2