в контроллере
import grails.converters.JSON
import asset//ur asset
class renderJsonController {
def renderJson() {
def result = asset.getJsonFromAsset()//Getter function in asset to get target json
render result as JSON
}
}
в .gsp
jQuery.ajax({
url: '${createLink(controller: 'renderJson', action: 'renderJson')}',
data: {},
type: 'POST',
dataType: 'json',
success: function (json) {
//!!get json here!!
},
error: function (xhr, ajaxOptions, thrownError) {
defaultAjaxError(xhr)
},
});