我有正在运行的代码,我希望在成功后移动到另一个页面,在c#中创建url并在返回时你可以看到字符串ic改变了可以做的事情。
C#代码
[System.Web.Services.WebMethod]
public static string timeFinished()
{
string url = "Summary.aspx?subjectid=" + HttpContext.Current.Session["subjectid"].ToString() + "&chapterid=" + HttpContext.Current.Session["chapterid"].ToString();
return url;
}
从Ajax返回
{"d":"Summary.aspx?subjectid=564\u0026chapterid=564
Ajax Java Scrpit
$.ajax({
type: "post",
url: "testchapter.aspx/timeFinished",
contentType: "application/json; charset=utf-8",
dataType: "text",
success: function (result) {
//
window.location = result;
}
});
答案 0 :(得分:1)
鉴于结果数据是正确的json,也许您可以尝试以下脚本:
$.ajax({
type: "post",
url: "testchapter.aspx/timeFinished",
contentType: "application/json; charset=utf-8",
dataType: "json", // change to json here!
success: function (result) {
window.location = result.d; // result is a JS object; access the d property
}
});