【发布时间】:2013-08-08 14:28:03
【问题描述】:
我有以下 WebMethod:-
[WebMethod(EnableSession = true)]
public static void OpenReport(string reportName)
{
Report report = reportsBll.GetReports().FirstOrDefault(x => reportQuestion != null && x.Id == reportQuestion.ReportId);
if (report != null) reportUrl = report.Url;
}
现在我希望将 report.Url 传递给这个 Jquery 方法:-
$('.ReportButton').click(function () {
var args = { reportName : '' };
$.ajax({
type: "POST",
url: "ReportsByQuestionsDetails.aspx/OpenReport",
data: JSON.stringify(args),
contentType: "application/json;charset=utf-8;",
success: function (data) {
alert('success');
document.location.href = reportUrl;
},
error: function () {
}
});
});
如何将 reportUrl 从 WebMethod 传递到 Jquery?
感谢您的帮助和时间
【问题讨论】:
-
你知道你的c#方法中的
void关键字是什么意思吗? -
是的,我必须更改它以返回 URL,但是我不知道如何将它传递给 Jquery
-
在更改 webmethod 后尝试在 jQuery 成功函数中检查
data的值。 -
我试图检查数据的值,它的对象对象
-
做
console.log(data),不是警报。