I have some working ruby and javascript. The javascript is this:
} else {
$.ajax("/values/" + facet + "/" + searchTerm, {
type:"GET",
dataType:"json",
success:function (res) {
callback(res);
}
});
Now I have a ruby method:
get '/facets' do
content_type :json
//return some json here
end
I am looking to write a groovy method that does the same thing, however I have never seen anything like this. How do you write a method like this in groovy? Thanks
You say in your title (but not the tags) that this is in Grails...
So you'd want to add (inside ValuesController.groovy
):
def facets() {
String search = params.id
render(contentType: 'text/json') {
[ term: search ]
}
}
That should return the json:
{ "term": "whatever searchTerm was in the JS" }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.