Return to Snippet

Revision: 11221
at January 28, 2009 12:44 by aadsm


Initial Code
function ajax(url, fn, async)
{
    var xmlhttp = new XMLHttpRequest();
    
    if ( async )
    {
        xmlhttp.onreadystatechange = function()
        {
            if ( xmlhttp.readyState == 4 && xmlhttp.status == 200 )
            {
                fn(xmlhttp);
            }
        }
    }
    xmlhttp.open("GET", url, async);
    xmlhttp.send(null);
    
    if ( !async )
    {
        fn(xmlhttp);
    }
}

Initial URL

                                

Initial Description

                                

Initial Title
Ajax simple call

Initial Tags
ajax

Initial Language
JavaScript