I am working on ASP.NET 3.5 App. I have $ajax jQuery function calling code-behind method with sending staff ID.
I want Response.Redirect to open from this method but getting following error
$.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) {
//
});
[WebMethod]
private static void GetRolesListFilteredByStaff_NotIn(string GivenStaffID)
{
Response.Redirect("/SelectRoleForStaff.aspx?staffID='GivenStaffID'");
}
my 2nd question is how to read staffID from url in new upload page
I have managed to call the require method but its not redirecting page...
[WebMethod]
public static void GetRolesListFilteredByStaff_NotIn(string GivenStaffID)
{
HttpContext.Current.Response.Redirect("/SelectRoleForStaff.aspx?staffID="+GivenStaffID);
}
Update your method to return the url to redirect like:
[WebMethod]
public static string GetRolesListFilteredByStaff_NotIn(string GivenStaffID)
{
return "SelectRoleForStaff.aspx?staffID=" + GivenStaffID;
}
And in your ajax success do this:
success: function (response) {
window.location = response;
// OR
window.location = response.d;
},