Delay a Grails controller’s response

Sometimes, for testing or development, you need to slow down an ajax response from the server.
In the Grails framework, to delay a controller’s response, do the following:

In the action you want to delay, insert:

Thread.sleep(5000)

as in:

def index() {
	Thread.sleep(5000)
	... do some work...
	render ... some response
    }

where 5000 is the milliseconds you want to delay by.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.