

def load(url, onreadystatechange=None, on_load_fn=None, async=False):
    setCompilerOptions('noDebug')
    wnd().status = ('Loading ' + url)
    req = createHttpRequest()
    if (onreadystatechange is None):

        def onreadystatechange(evnt):
            if ((req.readyState == 4) and ((req.status == 200) or (req.status == 0))):
                str = req.responseText
                wnd().status = ('Loaded ' + url)
                if (not (on_load_fn is None)):
                    on_load_fn(evnt, req)
    JS('@{{req}}.onreadystatechange = @{{onreadystatechange}};')
    req.open('GET', url, async)
    try:
        req.send(None)
        if async:
            return None
        while True:
            if ((req.status == 200) or ((req.status == 0) and req.responseText)):
                if (not (on_load_fn is None)):
                    on_load_fn(None, req)
                return req
            if ((req.status != 0) or (req.responseText != '')):
                break
    except:
        pass
    raise AjaxError('Synchronous error', req.status)

dataset/ETHPy150Open anandology/pyjamas/library/dynamic.py load/original