[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 /* 2 Copyright 2005 Rolando Gonzalez (rolosworld@gmail.com) 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 19 function getRequester() 20 { 21 try 22 { 23 if(window.XMLHttpRequest) 24 { 25 return new XMLHttpRequest(); 26 } 27 else if(window.ActiveXObject) 28 { 29 return new ActiveXObject("Microsoft.XMLHTTP"); 30 } 31 } 32 catch (e) 33 { 34 alert("You need a browser which supports an XMLHttpRequest Object.\nMozilla build 0.9.5 has this Object and IE5 and above."); 35 } 36 }; 37 38 /* 39 onreadystatechange Event handler for an event that fires at every state change 40 readyState Object status integer: 41 0 = uninitialized 42 1 = loading 43 2 = loaded 44 3 = interactive 45 4 = complete 46 responseText String version of data returned from server process 47 responseXML DOM-compatible document object of data returned from server process 48 status Numeric code returned by server, such as 404 for "Not Found" or 200 for "OK" 49 statusText String message accompanying the status code 50 */ 51 function Ajax(cb) 52 { 53 var me = this; 54 this.requester = getRequester(); 55 56 if(cb) 57 this.callback = cb; 58 else 59 this.callback = function(req) 60 { 61 return eval(req.responseText); 62 }; 63 64 this.requester.onreadystatechange = function(){ 65 switch(me.requester.readyState) 66 { 67 case 1: 68 case 2: 69 case 3: 70 break; 71 case 4: 72 var response = me.callback(me.requester); 73 break; 74 default: 75 alert("Error"); 76 break; 77 } 78 }; 79 80 this.state = function() 81 { 82 return me.requester.readyState; 83 }; 84 85 this.process = function(url, parameters){ 86 me.requester.open("POST", url, true); 87 me.requester.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 88 me.requester.setRequestHeader("Content-length", parameters.length); 89 //me.requester.setRequestHeader("Connection", "close"); 90 me.requester.send(parameters); 91 }; 92 };
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |