Hacker News new | ask | show | jobs
by jgillich 4349 days ago

    five.tooSlow = function() {
        var returnIn = new Date(new Date().valueOf() + 555);

        do {} while(new Date() < returnIn);

        return five();
    };
Finally a way to escape callback hell. I think somebody should write a jQuery.ajax plugin that calls the function repeatedly until a request is finished.
1 comments

That actually wouldn't work, as the response from the request would never be processed while you were looping.

You can make synchronous requests already though:

    req = new XMLHttpRequest
    req.open("some/url", "GET", false);
    req.send()