getWithRetry requests the URL again if an error occurs, up to a maximum of ten times.

Results

$.getWithRetry = function(url, k) {
    var countdown = 10;
    $.ajax({url:url, success:k, error:retry});
    function retry() {
        if (--countdown >= 0) {
            log('retry');
            $.ajax({url:url, success:k, error:retry});
        }
    }
};
$.getWithRetry('services/error', log);