【发布时间】:2011-02-09 00:49:38
【问题描述】:
我正在尝试使用 ASP.NET 网络服务来掌握 JQuery 和 JSON。 Webservice 返回这个结果:
{
MyResult: {
Ticket: {
"Author": "rd",
"CssClass": "RED",
"ExpirationDateTime": "2009-08-16T16:55:43.577+02:00",
"id": "38",
"Message": "We are going down",
"ModifiedDateTime": "2009-08-17T11:14:20.5+02:00",
"MoreInfo": null
}
}
}
在客户端,我使用 JQuery 来使用 ajax 函数获取结果,如下所示:
$.ajax({
type: "POST",
url: "TickerFeeder.asmx/GetTicket",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(resultJSON) {
//-- Please fill your code here for getting the first item from the array into variables
}
但是我错过了如何将 JSON 数组中的第一项检索到一些变量中的内容。像这样的东西(伪代码):
var message = resultJSON[0].Message
var cssclass = resultJSON[0].CssClass
任何人有提示,帮助?
感谢您的帮助 干杯 弗兰克
【问题讨论】:
标签: javascript jquery json