Skip to content

Instantly share code, notes, and snippets.

@ynonp
Created September 23, 2013 06:47
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 ynonp/6667146 to your computer and use it in GitHub Desktop.
Save ynonp/6667146 to your computer and use it in GitHub Desktop.
(function(global, $) {
function PersonalData() {
var numRetries = 3;
var sendData = function() {
$.ajax({
url: '/api/data',
type: 'POST',
error: function(err) {
console.log('err: ' + err);
numRetries--;
if ( numRetries > 0 ) {
setTimeout(sendData, 3000);
} else {
numRetries = 3;
}
},
success: function() {
console.log('success');
}
})
};
return {
sendData: sendData
};
}
this.PersonalData = PersonalData;
}(this, jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment