【发布时间】:2011-04-25 01:54:08
【问题描述】:
我使用在 Internet 上找到的一些教程整理了一些 jQuery AJAX 代码。我是 jQuery 新手,想学习如何做得更好。我有一位同事使用大量 jQuery 构建了一个漂亮的 Web 应用程序。
这里我最困惑的是:为什么在引用我的 web 方法的响应时必须使用“.d”,它代表什么?
// ASP.net C# code
[System.Web.Services.WebMethod]
public static string hello()
{
return ("howdy");
}
// Javascript code
function testMethod() {
$.ajax({
type: "POST",
url: "ViewNamesAndNumbers.aspx/hello",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
alert(msg); // This doesn't display the response.
alert(msg.d); // This displays the response.
} // end success:
}) // end $.ajax
【问题讨论】:
标签: asp.net jquery json serialization