

def ajax_dlink(idname, url, on_load_fn):
    global running_timeout, timeout_idname, timeout_url, timeout_on_load_fn, redo_timeout, timeout_id
    from __pyjamas__ import doc
    body = doc().body
    from __javascript__ import clearTimeout
    if timeout_id:
        clearTimeout(timeout_id)

    def onreadystatechange():
        if (xhtoj.readyState == 4):
            jsnode = 0
            if (xhtoj.status == 200):
                txt = xhtoj.responseText
                jsnode = None
                if idname:
                    jsnode = DOM.getElementById(idname)
                if (jsnode is None):
                    jsnode = DOM.createElement('script')
                activate_javascript(txt)
                if (not (on_load_fn is None)):
                    wnd().alert(on_load_fn)
                    test_fn()
                return 1
            else:
                jsnode = DOM.getElementById(idname)
                if (not (jsnode is None)):
                    jsnode.innerHTML = xhtoj.status
    xhtoj = createHttpRequest()
    xhtoj.onreadystatechange = onreadystatechange
    xhtoj.open('GET', url, True)
    xhtoj.send('')
    return 0

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