2016-02-13 135 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 –

相關問題