9 A simple handler for Async Requests
11 The returned XML file should contain all information needed to cause a page effect,
12 rather than creating a custom response for each request, which is not possible due
13 to the security issues that prevent the creation of instances of XMLHttpRequest()
14 with unique properties. It's better this way, anyhow :-/
16 See XMLRoute.js to write handlers for async responses.
20 var req = new Request();
22 req.send("scraps/add.pl", "?first=3&second=2", "POST");
27 Chris Carpita <csc32@cornell.edu>
33 JSAN.use("CXGN.Base");
34 JSAN.use("CXGN.XMLroute");
42 this.isValid = function() { return this.valid }
43 this._onReadyState = function() {
44 if(req.readyState==4){
45 // document.write(req.responseText);
46 XMLroute.call(this, req.responseXML);
49 this.send = function(url, parameters, method) {
50 if(!method) { method = "POST" }
51 if(method == "POST") {
52 req.open("POST", url, true);
53 req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
54 req.setRequestHeader("Content-length", parameters.length);
55 req.setRequestHeader("Connection", "close");
58 else if(method == "GET") {
59 req.open("GET", url + parameters, true);
63 if(window.XMLHttpRequest) {
64 req = new XMLHttpRequest();
66 else if (window.ActiveXObject) {
67 try { req = new ActiveXObject("Msxml2.XMLHTTP");}
69 try { req = new ActiveXObject ("Microsoft.XMLHTTP");}
70 catch (e) { return false }
75 req.onreadystatechange = function() { loader._onReadyState.call() }