页面重新加载和/或页面重定向无法在$ ajax成功函数中工作

时间:2015-09-29 08:01:20

标签: jquery ajax webforms asp.net-3.5

我正在使用$ajax jQuery函数将数据发布到ASP.NET 3.5 webform的代码隐藏方法,该方法工作正常,除了window.location重定向和/或location.reload没有解雇。

我也试过widnow.location.href但仍然没有成功。我正在接收警报,要求工作人员已成功从选定角色中删除。我不确定我在这里缺少什么

$.ajax({
    url: 'SelectRoleToRemove.aspx/RemoveRoleFormSelectStaffProfile',
    type: "POST",
    data: JSON.stringify({ GivenStaffID: selectStaffID, GivenRoleID: selectedRoleID }),
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (response) {
        alert(response.d);

        if (response.d == "The Staff Been Removed From Selected Role Successfully") {

            widnow.location = "RemoveStaffFromRoles.aspx?staffID=" + selectStaffID;

            location.reload();
        }
        else {
            window.location = "Roles.aspx";
        }

    },
    failure: function (response) {
        alert(response.d);
    }
}).done(function (response) {
    //
});

1 个答案:

答案 0 :(得分:2)

错字widnow.location,应为window.location或尝试location.href