Run ajax in certain time interval in Magento2

ajaxmagento2

I have added ajax to show a text which is fetched from my scope config(The value is given in the store->configuration). In my controller I am getting the value using scope config and used echo in it.
In my ajax function, I am using the url of my controller to print the data in html div tag. I want to make the ajax function running all the time, so that if I change the value the ajax has to update the text automatically without any action.

Best Answer

use https://www.w3schools.com/jsref/met_win_settimeout.asp

setTimeout(function(){ callAjaxRequest(); }, 3000);
Related Topic