How to make a ajax request to route and get its response?Created 4 years ago by dilusha100
I create messaging app and I need to mark messages read without reloading the page. But when I make a ajax request to the route, it nothing happens but returning the html code of the welcome page. So, is there any way to make a ajax request using jquery or any related library?
finnito — 4 years ago
I'm not sure if it's a bit overkill, but you could definitely follow @ryanthompson's guide on making a custom Ajax form (https://pyrocms.com/help/developer-tools/form-builders/defining-custom-ajax-forms-in-twig) and then just embed a bunch of tiny forms with a hidden input that contains the id(?) of the comment that you are trying to mark as read.
Have you routed the controller for this? Maybe share a little code (controller, route, etc) if you can.