/* * This file creates the instance of xmlHttpRequest object, sends and * receives the request and response respectively. */ /* * Static script to instantiate XMLHttp object for different browsers. */ //0var clientHttpHandler; //clientHttpHandler = create(); function ServerXMLHTTPRequest() { this.clientHttpHandler = create(); this.httpMethod = "GET"; this.serverUrl = ""; this.isAsync = true; this.respFunc = ""; this.send = function () { if(this.serverUrl != "") { this.clientHttpHandler.open(this.httpMethod, this.serverUrl, this.isAsync); this.clientHttpHandler.onreadystatechange = this.respFunc; this.clientHttpHandler.send(null); } }; this.receive = receive; //this.datareceived = function () { return (this.receive()) }; } /* This method creates the xmlHttpRequest object and returns it. */ function create() { var xmlHttpRequest = false; //Internet Explorer try { xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); //alert("creating new Msxml2.XMLHTTP obj"); } catch (xml2Exception) { try { xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); alert("creating new Microsoft.XMLHTTP obj"); } catch (xmlException) { xmlHttpRequest = false; } } //Netscape, Mozila, Firefox, Safari, Opera if (!xmlHttpRequest && typeof XMLHTTPRequest == 'undefined') { try { //alert("creating new ff obj"); xmlHttpRequest = new XMLHttpRequest(); } catch (genException) { XMLHttpRequest = false; } } if (!xmlHttpRequest && window.createRequest) { try { xmlHttpRequest = window.createRequest(); } catch (e) { xmlHttpRequest=false; } } /*if(xmlHttpRequest == false) alert ("Browser Initialization Error !!\nBrowser does not support all functionalities for the chat."); */ return xmlHttpRequest; } /* * This method sends the request to the server url according to the * passing parameters. It sets the users's response function to the * onreadystatechange event of the xmlHttpRequest object. */ /* function send() { this.clientHttpHandler.open(this.httpMethod, this.serverUrl, this.isAsync); this.clientHttpHandler.onreadystatechange = this.respFunc; this.clientHttpHandler.send(null); } */ /* function createAndSend(httpMethod, serverUrl, isAsync, respFunc) { var freshClientHttpHandler = create(); clientHttpHandler = freshClientHttpHandler; clientHttpHandler.open(httpMethod, serverUrl, isAsync); clientHttpHandler.onreadystatechange = respFunc; clientHttpHandler.send(null); } */ /* * This method checks the state and the status of the response and * depending on that fetches the response text. * readystate: 0 - uninitialized, 1 - loading, 2 - loaded, 3 - interactive, 4 - complete */ function receive() { try { if (this.clientHttpHandler.readyState == 4) // Completed { var status = this.clientHttpHandler.status; if (status == 200) // "OK" { return true; } else if (status == 403) // "Forbidden" { //alert("Error: Access denied. Please check the permissions!"); } else if (status == 404) // "URL Not Found" { //alert("Error: URL not found. Please check the URL!"); } else // Miscellaneous { //alert("Error: status code " + status); } } return false; } catch (genException) { } } function destructObj(objToDestroy) { //alert("deleting Obj"); objToDestroy = null; }