我的控制器getJson
中有一个功能。它工作正常;我得到了一个AJAX响应。
def getJson = {
// BillingController obj= new BillingController()
// ResultSet results = obj.showBillingPeriod()
def c= BillingPeriod.createCriteria()
def results = c{
and{
max("billingStartDate")
max("billingEndDate")
}
maxResults(1)
order("billingStartDate", "desc")
}
render results as JSON
}
var baseUrl = "${createLink(controller:'billingPeriod', action:'getJson')}"
new Ajax.Request(baseUrl, {
method: 'get',
asynchronous: true,
onSuccess: function(req) {update(req)}
});
[{"class":"com.indivar.cmcs.master.BillingPeriod","id":53,"billingEndDate":"25-02-2011","billingStartDate":"28-02-2011","dateCreated":"17-02-2011","enteredBy":0,"lastUpdated":"17-02-2011"}]
现在,我想从billingEndDate
获取billingStartDate
和response
的值,并将其显示在警告中。我尝试了一切,但它没有奏效。我怎么能这样做?
答案 0 :(得分:0)
onSuccess: function(req) {
alert(req.responseJSON["billingStartDate"]);
alert(req.responseJSON["billingEndDate"]);
}