简体   繁体   中英

How trigger an action via ajax automatically without click after 2 minutes the HTML is loaded

I need to call an action automatically via ajax to refresh the current page after 2 minutes it has been loaded.

I know to trigger an ajax call as a URL link using:

<s:url id="ajax" action="AjaxAction!ajaxCall"/>
<sx:a href="%{ajax}" targets="divAjax" loadingText="Loading...">Ajax Call</sx:a>

<sx:div id="divAjax"></sx:div>

What I am looking for is to specify 120 seconds in order to trigger automatically an ajax call that will refresh the view (webpage) without clicking anything.

Appreciate your help

Using Struts2 jQuery plugin I was able to automatically trigger an action call after 5000 milliseconds

This is the code example

<sj:div id="div4" href="%{ajaxCall}" updateFreq="5000">
    <s:url id="ajaxCall" value="UpdateAction!methodName"/>
</sj:div>

Regards

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM