Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bfolkens
Last active December 9, 2015 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bfolkens/25f739521ddca35f8115 to your computer and use it in GitHub Desktop.
Save bfolkens/25f739521ddca35f8115 to your computer and use it in GitHub Desktop.
Retrieve image response from server
var key = 'YOUR API KEY';
var token = 'THE TOKEN FROM THE REQUEST RESPONSE';
var poll = function() {
$.ajax({
'async': true,
'crossDomain': true,
'url': 'https://api.cloudsightapi.com/image_responses/' + token,
'method': 'GET',
'headers': {
'authorization': 'CloudSight ' + key,
'cache-control': 'no-cache'
}
}).done(function(data) {
if (data.status == 'not completed') {
console.log('in progress');
setTimeout(poll, 1000);
} else {
console.log(data);
}
}).fail(function(jqXHR, textStatus, errorThrown) {
console.log('Error retrieving token: ' + errorThrown);
});
}
poll();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment