It seems to be the frontend responsability to do this… Maybe some javascript, and a backend api to provide data on request?
It seems like a problem ajax solved years ago. But depending on the context, You might prefer other solution. Like loading all data (if the set is limited) client side and caching them with IndexDb, or local_storage. This will avoid round trip to the server.
There is also drab, to make the change server side.