/** * Various Ajax utilities. */ /** * return and XMLHttpRequest object, or null if not supported. */ function getAjaxRequestor() { var request; if(window.XMLHttpRequest) { //Mozilla-based browsers request = new XMLHttpRequest(); } else if(window.ActiveXObject) { // IE stuff request=new ActiveXObject("Msxml2.XMLHTTP"); if(!request) { request=new ActiveXObject("Microsoft.XMLHTTP"); } } return request; } /** * Prepare a request. This always uses GET and makes asynch requests * Params. All you need to do is to call 'send()' on the request: * request: the HttpRequest to use (onreadystatechange must be set before this call) * url: the URL to query * args: as dict of key/value pairs representing optional args * handler: the response handler */ function makeAjaxRequest(request, url, args, handler) { if(args) { url += "?"; for(var k in args) url += k + "=" + encodeURIComponent(args[k]) + "&"; } var argSep = url += ((url.indexOf('?') >= 0) ? "&" : "?") + "rndAjaxArg=" + Math.random(); request.onreadystatechange = handler; request.open('GET',url,true); request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); request.send(""); }