Autorefreshing datatable in a jquery-UI tab

Autorefreshing datatable in a jquery-UI tab

In my index page, I have a jqueryUI tab widget with 5 ajax tabs. In one of the tabs, I have a datatable that should auto-refresh every 5 seconds.

I have created the datatable in the required tab, and am autorefreshing it via a setInterval. Everything works as expected.

But when I click on some other tab, I want that autorefresh cleared (because its pointless, user is no more looking at that tab).

How can I achieve this? How can I clear the interval defined inside the ajax content of a jquery UI tab from outside the tab when some other tab is active and this one goes inactive?