json - ajax problem in fetching value from response -
i have function in controller, getjson
. works fine; ajax response.
code
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 json }
ajax
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"}]
now want fetch value of billingenddate
, billingstartdate
response
, show in alert. tried did not work. how can that?
onsuccess: function(req) { alert(req.responsejson["billingstartdate"]); alert(req.responsejson["billingenddate"]); }
Comments
Post a Comment