Search code examples
javascriptjqueryajaxgrailscontroller

Grails: Should I use a controller or javascript to run queries and update the page accordingly?


I am fairly new to Grails and Frameworks in general. I'm trying to program a little webshop in which you can select a category and subcategories of products (select element and checkboxes) which are then requested via sql and displayed. My problem is that both the categories and subcategories are also tables in my database. This means that I cannot hardcode controller actions rendering a specific view for every category. Should I do all that with jquery and ajax and stay in one view? Or should I use the same controller action for everything? That would result in a strange reloading of the view every time the selection is changed. I guess that this is a rather stupid question resulting from lack of knowledge about the framework in general but I really am stuck and would be very thankful if someone could help me.

Thanks already! Alex


Solution

  • javascript is mainly used for your frontend. Use it for accessing your API on your backend, not for replacing your controllers.