Tox*_*xic 2 c# ajax jquery webforms asp.net-3.5
我正在使用ASP.NET 3.5 App.我有$ ajax jQuery函数调用代码隐藏方法与发送人员ID.
我希望Response.Redirect从此方法打开但是会出现以下错误
$.ajax({
url: 'AddUserInRole.aspx/GetRolesListFilteredByStaff_NotIn',
type: "POST",
data: JSON.stringify({ GivenStaffID: selectStaffIDToAddRole }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert(response.d);
},
failure: function (response) {
alert(response.d);
}
}).done(function (response) {
//
});
Run Code Online (Sandbox Code Playgroud)
[WebMethod]
private static void GetRolesListFilteredByStaff_NotIn(string GivenStaffID)
{
Response.Redirect("/SelectRoleForStaff.aspx?staffID='GivenStaffID'");
}
Run Code Online (Sandbox Code Playgroud)
我的第二个问题是如何在新的上传页面中从url读取staffID
我已设法调用require方法,但它没有重定向页面...
[WebMethod]
public static void GetRolesListFilteredByStaff_NotIn(string GivenStaffID)
{
HttpContext.Current.Response.Redirect("/SelectRoleForStaff.aspx?staffID="+GivenStaffID);
}
Run Code Online (Sandbox Code Playgroud)
更新您的方法以返回重定向的网址,如:
[WebMethod]
public static string GetRolesListFilteredByStaff_NotIn(string GivenStaffID)
{
return "SelectRoleForStaff.aspx?staffID=" + GivenStaffID;
}
Run Code Online (Sandbox Code Playgroud)
在你的ajax成功中做到这一点:
success: function (response) {
window.location = response;
// OR
window.location = response.d;
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5489 次 |
| 最近记录: |