[ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 2 function Requester() 3 { 4 this.action = null; 5 this.XML = null; 6 this.commInterface = null; 7 this.targetId = null 8 // Initialise XMLHttpRequest object 9 this.resetXMLHR(); 10 11 return true; 12 } 13 14 15 /** 16 * Check if the XMLHttpRequest object is available 17 */ 18 Requester.prototype.isAvailable = function(){ 19 return (this.commInterface == null) ? false : true; 20 } 21 22 23 /* Execute the action which has been associated with the completion of this object */ 24 Requester.prototype.executeAction = function() { 25 // If XMLHR object has finished retrieving the data 26 27 if (this.commInterface.readyState == 4) { 28 // If the data was retrieved successfully 29 try { 30 if (this.commInterface.status == 200) { 31 this.responseText = this.commInterface.requestXML; 32 this.action(); 33 } 34 // IE returns status = 0 on some occasions, so ignore 35 else if (this.commInterface.status != 0){ 36 alert("There was an error while retrieving the URL: " + this.commInterface.statusText); 37 } 38 } 39 catch (error){} 40 } 41 return true; 42 } 43 44 45 /* Return responseText */ 46 Requester.prototype.getText = function() { 47 return this.commInterface.responseText; 48 } 49 50 51 /* Return responseXML */ 52 Requester.prototype.getXML = function() { 53 return this.commInterface.responseXML; 54 } 55 56 57 /* Initialise XMLHR object and load URL */ 58 Requester.prototype.loadURL = function(URL, CGI) { 59 this.resetXMLHR(); 60 61 this.commInterface.open("GET", URL + "?" + CGI); 62 var e=(document.charset||document.characterSet||'ISO-8859-8-i'); 63 this.commInterface.setRequestHeader("Content-Type", "text/html; charset="+e); 64 this.commInterface.setRequestHeader('Accept-Charset',e) 65 this.commInterface.send(null); 66 67 return true; 68 } 69 70 71 /* Turn off existing connections and create a new XMLHR object */ 72 Requester.prototype.resetXMLHR = function() { 73 var self = this; 74 75 if (this.commInterface != null && this.commInterface.readyState != 0 && this.commInterface.readyState != 4) { 76 this.commInterface.abort(); 77 } 78 79 try { 80 this.commInterface = new XMLHttpRequest(); 81 } 82 catch (error) { 83 try { 84 this.commInterface = new ActiveXObject("Microsoft.XMLHTTP"); 85 } 86 catch (error) { 87 return false; 88 } 89 } 90 91 this.commInterface.onreadystatechange = function() { 92 self.executeAction(); 93 return true; 94 }; 95 return true; 96 } 97 98 /* Assign the function which will be executed once the XMLHR object finishes retrieving data */ 99 Requester.prototype.setAction = function(actionFunction,part) { 100 this.action = actionFunction; 101 return true; 102 } 103 104 105 Requester.prototype.setTarget = function(targetId) { 106 this.targetId = targetId; 107 return true; 108 } 109 110 Requester.prototype.getTarget = function() { 111 return this.targetId; 112 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |