Last active
December 9, 2015 08:32
-
-
Save bfolkens/25f739521ddca35f8115 to your computer and use it in GitHub Desktop.
Retrieve image response from server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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