【发布时间】:2016-03-30 06:56:05
【问题描述】:
我正在尝试从 JQuery 调用中获取 WebMethod 的返回值,但我收到“未定义”消息。下面是我的代码
$.ajax({
type: "POST",
url: "Receipt/BarcodeEntered",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "text",
success: function (msg) {
alert(msg.d); // This displays "Undefined"
alert(msg); // This displays the whole html
}
});
WebMethod 在下面
[WebMethod]
public static string BarcodeEntered()
{
return "test_string";
}
如何从 WebMethod 获取值并将其显示在客户端?
【问题讨论】:
标签: c# jquery asp.net webforms