How do I customize the Javascript polling?

So our Vaadin app doesn’t use WebSockets and has to rely on the Javascript polling. I need to be able to check the response of the AJAX call before Vaadin tries to do anything with it. How would I go about doing this?