diff options
Diffstat (limited to 'javascript/bitweaver.js')
| -rw-r--r-- | javascript/bitweaver.js | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/javascript/bitweaver.js b/javascript/bitweaver.js index b412660..eff7a1e 100644 --- a/javascript/bitweaver.js +++ b/javascript/bitweaver.js @@ -1,4 +1,4 @@ -// $Header: /cvsroot/bitweaver/_bit_util/javascript/bitweaver.js,v 1.40 2009/03/11 22:04:25 tekimaki_admin Exp $ +// $Header: /cvsroot/bitweaver/_bit_util/javascript/bitweaver.js,v 1.41 2009/03/26 20:43:26 spiderr Exp $ // please modify this file and leave plenty of comments. This file will be // compressed automatically. Please make sure you only use comments beginning @@ -990,6 +990,54 @@ BitBase = { $(w1).value = p; $(w2).value = p; $(w3).value = p; + }, + + /** XHConn - Simple XMLHTTP Interface - bfults@gmail.com - 2005-04-08 ** + ** Code licensed under Creative Commons Attribution-ShareAlike License ** + ** http://creativecommons.org/licenses/by-sa/2.0/ ** + + var fnWhenDone = function ( pResponse ) { + alert( pResponse.responseText ); + }; + var ajax = new BitBase.SimpleAjax(); + ajax.connect("mypage.php", "POST", "foo=bar&baz=qux", fnWhenDone); + + **/ + + "SimpleAjax": function() { + var xmlhttp, bComplete = false; + try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } + catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } + catch (e) { try { xmlhttp = new XMLHttpRequest(); } + catch (e) { xmlhttp = false; }}} + if (!xmlhttp) return null; + this.connect = function(sURL, sMethod, sVars, fnDone) { + if (!xmlhttp) return false; + bComplete = false; + sMethod = sMethod.toUpperCase(); + + try { + if (sMethod == "GET") { + xmlhttp.open(sMethod, sURL+"?"+sVars, true); + sVars = ""; + } else { + xmlhttp.open(sMethod, sURL, true); + xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1"); + xmlhttp.setRequestHeader("Content-Type", + "application/x-www-form-urlencoded"); + } + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState == 4 && !bComplete) { + bComplete = true; + fnDone(xmlhttp); + } + }; + xmlhttp.send(sVars); + } + catch(z) { return false; } + return true; + }; + return this; } }; |
