【发布时间】:2017-02-14 08:42:58
【问题描述】:
我正在尝试向 webmethod 发送参数。我不能改变网络方法,因为它不是我的。我只需要将它与 jquery 一起使用。
Web 方法示例;
[WebMethod]
public static string getValue(int id, out string name)
{
name = (id * 5).ToString();
return "Success";
}
jQuery 示例;
$(document).ready(function () {
getValue();
});
function getValue() {
$.ajax({
url: "../WebMethods.aspx/getValue",
type: 'post',
contentType: "application/json",
dataType:"json",
data: JSON.stringify({ id: 0, name: "" }),
success: function (data) {
console.log(data);
}
});
}
我需要成功函数中的名称值。是否可以?我可以在 c# 中调用它及其工作。但我需要它以 ajax 方法工作。
【问题讨论】:
标签: jquery asp.net ajax out-parameters