I've been struggling creating a reload functionality when a getJSON call fails. This is my current code:
        function get_stuff(page) {
        fPage = 'http://mywebsite.com/' + page + '.json';
        $.getJSON(fPage, function (data) {
            // Stuff
        })
        .fail(function () { // Call failed
            get_stuff(page);
        });
This code does reload the function, but a couple of times every millisecond. I thought of adding a delay, however I didn't manage to find a function (I tried delay(ms) and sleep(ms))
I hope anyone is able to help me out