Search code examples
javascriptjqueryasp.net-mvc-3actionmethod

Call action method and return new View using Javascript in MVC3


I have a scenario where I need to use javascript to call a action method using parameters and render the view that is returned by the action method. I have seen examples where action method is called and partial view is updated. But I am trying to execute the action method and a new view, can this be done ? please help. thanks

function OnRowSelect(e) {
        var form = $(this);
        var taskInstanceUid = e.row.cells[13].innerHTML;
        var so = e.row.cells[12].innerHTML;
        var tabText;
     $.ajax({
            type: 'POST',
            cache: false
        })
         .success(function (result) {
               $.post("OrderInformation", { taskInstanceUid: taskInstanceUid });
       });

Solution

  • If you are going to update the entire view, couldn't you just direct the user to the URL that return the view?

    <script type="text/javascript">
    window.location.href = "http://yourdomain.com/controller/action/?parameter1=something";
    </script