2016-02-13 134 views
-1

您好我有我的asp.net mvc应用程序中的jquery window.location.href问题我在做什么是我有一个网格视图的帮助下Html.actionlink我呼吁其删除记录后,我必须重定向或在阿贾克斯成功重新加载相同的观点我的网页删除从数据库中, 行Ajax请求:window.location.href在Asp.Net MVC应用程序谷歌浏览器不工作

我的WebGrid

@grid.GetHtml(
    columns: grid.Columns(
    grid.Column("ID", "ID",canSort:false), 
    grid.Column("Area", "Area",canSort:false), 
    grid.Column("", header: "Actions", style: "grid-actions", format: @<text> 
@Html.ActionLink("Delete", null, "", new { }, new { data_id = item.ID, @class = "Delete-Row" }) 
</text>) 
    )) 

而且我JQuery的阿贾克斯

$(".Delete-Row").on('click', function() { 
var Id = $(this).data("id"); 
      var isTrue = confirm("Are you want To delete") 
      if (isTrue) { 
       $.ajax({ 
        url: '@Url.Action("DeletaArea", "SetupHr")', 
        data: { id: Id }, 
        type: "GET", 
        success: function (data) { 
         window.location.href = '@Url.Action("IndexArea", "SetupHr")'; 
        }, 
        error: function (data) { 
         window.location.href = '@Url.Action("IndexArea", "SetupHr")';      } 
       }); 
      } 
      else { 
       return false; 
      } 
     }); 
+0

嗯......你确定你的Ajax调用的工作:能够与

location.reload(); 

这样做呢? – LMK

+0

Ajax工作正常, –

+0

基本上我不会采取我的目标位置,通过'Html.actionlink'它创建一个默认的一些东西像href =“hrms /”帐户/ IndexArea/ –

回答

0

我不确定为什么Razor无法生成@ Url.Action方法,因为我认为它们看起来正确。

但是,在你的问题你提到重新加载页面也会很好?

success: function (data) { 
        location.reload(); 
       }, 
       error: function (data) { 
        location.reload(); 
       } 
      }); 
+0

亲爱的不工作在Firefox中 –

+0

@ImranLuhur当然可以,只是做到了。 –

+0

@ImranLuhur FF支持记录在:https://developer.mozilla.org/en-US/docs/Web/API/Location/reload –

相关问题