Skip to content

Instantly share code, notes, and snippets.

@natecavanaugh
Created July 17, 2012 17:08
Show Gist options
  • Save natecavanaugh/3130624 to your computer and use it in GitHub Desktop.
Save natecavanaugh/3130624 to your computer and use it in GitHub Desktop.
poll_for_brad.jsp
<aui:script use="aui-io-request">
var timer;
var request = A.io.request(
'/url'
{
dataType: 'json',
on: {
success: function(event) {
var response = this.get('responseData');
var responseStatus = response.status;
if (responseStatus == 0 || responseStatus == 1) {
if (!timer) {
timer = A.later(500, Liferay, function() {
request.start();
}, null, true);
}
}
else {
if (timer) {
timer.cancel();
}
}
},
failure: function(event) {
if (timer) {
timer.cancel();
}
}
}
}
);
</aui:script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment