window.location.href not redirecting in IE 8

556 Views Asked by At

I am updating a textbox inside grid in MVC 4. The value is updated but the page is not refreshed and redirected to the specified actionresult in IE 8.
Controller code

public JsonResult UpdateCart(int Quantity, int ProductID)
{
  if (System.Web.HttpContext.Current.Session["UserID"] != null)
   {             
    objcartresponse.ProductID           = ProductID;
    objcartresponse.Quantity            = Quantity;                
    objcart.UpdateCart(objcartresponse);
    return Json(new
                {
                    redirectUrl = Url.Action("ShoppingCart", "Cart"),
                    isRedirect = true
                });
     }
     else
     {
     return Json(new
                {
                    redirectUrl = Url.Action("Login", "Account"),
                    isRedirect = true
                });
     }
 }

jQuery code

$(document).ready(function () {
 $(function () {
       $('.edit-mode').hide();
       $('.edit-user, .cancel-user').on('click', function () {
       var tr = $(this).parents('tr:first');
        tr.find('.edit-mode,.display-mode').toggle();
 });    
  $('.save-TZ').on('click', function () {
       var tr = $(this).parents('tr:first');
       var id = $(this).attr('id');
       var qty = tr.find("#Quantity").val();
       tr.find('.edit-mode,.display-mode').toggle();
       var Wishlist = { "Quantity": qty,  "ProductID": id    };
       $.ajax({
            url: '/Cart/UpdateCart/',
            data: JSON.stringify(Wishlist),
            type: 'POST',
            contentType: 'application/json; charset=utf-8',
            success: function (json) {
                     if (json.isRedirect) {
                     window.location.href = json.redirectUrl;
            }
               }
                    });
                });
            });
        });

I tried changing the window.location.href in jquery to window.location. But its also not working in IE 8. But in other browsers like chrome & FF its working fine. Any suggestions to make the code to work in IE 8 ?? Is there any mistake in the code.

0

There are 0 best solutions below