2006-05-24

Sarissa & XMLHttpRequest

function gettime( ) { return (new Date()).getTime(); }

...

if( !Sarissa.IS_ENABLED_XMLHTTP) { critical_error( ); return; }

// uniq is needed for IE, otherwise we get a cached copy
var r ="/do?uniq=" + gettime( ) + "&";

r +='foo=' +bar; // ...

var xmlhttp =new XMLHttpRequest();  // Sarissa makes this cross-browser

xmlhttp.onreadystatechange =function( )
{
  if (xmlhttp.readyState ==4)
  {
    if (xmlhttp.status ==200)
    {
      callback( xmlhttp.responseText);  // or something...
    }
    else
    {
      resolve_error( xmlhttp.status);  // or something...
    }
  }
}

xmlhttp.open( "GET", r, true);
xmlhttp.send( null);