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

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -