What Goes in the Controller for an AJAX get request in GRAILS -


i have ajax call in view,

var ajaxdata= $.ajax({ type: "get", url: "${createlink(controller:'profile',action:'ajaxlist')}", success: function(data) {     }   }); 

i created method in profilecontroller.groovy class in order return "data" call, don' know how format controller correctly. here want return. model, profile, has name , description. want return hash object key name , value description. there way in controller ajax call returns hash. aprpeciated. thanks!

in controller's ajaxlist action build model want it, usual, , instead of return model @ end want render model json.

for example,

class profilecontroller {     def ajaxlist() {         def profiles = profile.list()         def model = profiles.collect { [(it.name): it.description] }         render model json     } } 

and if want use same list action returning different formats, @ using withformat.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -