How to refresh same element without page reload in Thymeleaf using spring webflow?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to refresh same element without page reload in Thymeleaf using spring webflow?

prabakaran
Hi Guys,

I am using spring webflow in Thymeleaf to achieve AJAX request (dojo.js, Spring.js, Spring-Dojo.js)
Here is my code

<div id="refreshDiv" th:fragment="refreshFragment">
        Test
</div>

<script language="javascript" type="text/javascript"> Spring.addDecoration(new Spring.AjaxEventDecoration({ elementId : 'refresh', event : 'onclick', params : { fragments : "refreshFragment"} })); </script>
// CONTROLLER
        @RequestMapping(value = "/refresh", method = RequestMethod.GET)
    public String trial(Model model){
                model.addAttribute("ancText", "Test-"+randomText);
                return refresh;
        }

I want refresh same element which trigger AJAX event. But it fails to refresh without page reload.
1st time without page refresh (AJAX)
2nd time page refreshing
3rd time without page refresh (AJAX)
4th time page refreshing...... and so on (alternatively works)....

What I missed here?
Could you please help me to understand and refresh (refreshFragment) fragment without page reload?

Thanks