Widget With Controller And Database Interaction

Hi all,

I am thinking about creating a widget for some code I want to re-use, but am not sure if it is possible. I have a country/city selection function on my website which consists of 2 dropdown lists (country/city) and then an “Add” button which populates the selection into a container div. There is also some small javascript to handle removing selected entries and detecting duplicates. What I would like to do is move all of this functionality out into a widget, so it can be re-used on another page in my website. Given the fact that an Ajax request is used when the ‘Country’ is changed in order to populate the ‘City’ dropdown with results from a database query, is this going to be a difficult task, or maybe not even possible?

You can create an Action class that responds to the AJAX request and works in conjunction with your widget.

Thanks, looks like that will work for me