function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ravi Sankar 12Ravi Sankar 12 

Call timeout function if the response takes more than 30 sec

I appreciate if anyone can give me a solution for this. I have a button on a lightning page. Onclick it makes a call to external system and shows the response in a model. I want to show an error message if the response delays by 30 sec to the agent and refresh the page. Can I use something like below? If yes please help me if there are any mistakes in using this. Also, I want the time out to be fired only if the response delays by 30 sec. If the agent gets the response in 30 sec, timeout error shouldnt be fired.
I appreciate your help.
onclick="{!c.callServerMethod;setTimeout('alert('time exceeded 30 sec.!')', 30000)}"