3 // http://jquery.com/docs/ajax/
5 if ( typeof XMLHttpRequest == 'undefined' && typeof window.ActiveXObject == 'function') {
6 var XMLHttpRequest = function() {
7 return new ActiveXObject((navigator.userAgent.toLowerCase().indexOf('msie 5') >= 0) ?
8 "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP");
12 $.xml = function( type, url, data, ret ) {
13 var xml = new XMLHttpRequest();
16 xml.open(type || "GET", url, true);
19 xml.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
21 xml.onreadystatechange = function() {
22 if ( xml.readyState == 4 ) {
24 $.triggerAJAX( $.httpData(xml) );
32 $.httpData = function(r,type) {
33 return r.getResponseHeader("content-type").indexOf("xml") > 0 || type == "xml" ?
34 r.responseXML : r.responseText;
37 $.get = function( url, ret, type ) {
38 $.xml( "GET", url, null, function(r) {
39 if ( ret ) ret( $.httpData(r,type) );
43 $.getXML = function( url, ret ) {
44 $.get( url, ret, "xml" );
47 $.post = function( url, data, ret, type ) {
48 $.xml( "POST", url, $.param(data), function(r) {
49 if ( ret ) ret( $.httpData(r,type) );
53 $.postXML = function( url, data, ret ) {
54 $.post( url, data, ret, "xml" );
57 // Global AJAX Event Binding
59 // http://jquery.com/discuss/2006-March/000415/
61 $.fn.handleAJAX = function( callback ) {
62 $.ajaxHandles = $.merge( $.ajaxHandles, this.cur );
63 return this.bind( 'ajax', callback );
67 $.triggerAJAX = function(data){
68 for ( var i = 0; i < $.ajaxHandles.length; i++ )
69 triggerEvent( $.ajaxHandles[i], 'ajax', [data] );
72 // Dynamic Form Submission
73 // Based upon the mailing list post at:
74 // http://jquery.com/discuss/2006-March/000424/
76 $.fn.serialize = function(callback) {
77 return this.each(function(){
80 .find("input:checked,hidden,text,option[@selected],textarea")
81 .filter(":enabled").each(function() {
82 a[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
84 $.xml( this.method || "GET", this.action || "", $.param(a), callback );
88 $.param = function(a) {
91 s[s.length] = i + "=" + encodeURIComponent( a[i] );
95 $.fn.load = function(a,o,f) {
97 // I overwrote the event plugin's .load
98 // this won't happen again, I hope -John
99 if ( a && a.constructor == Function )
100 return this.bind("load", a);
103 if ( o && o.constructor == Function ) {
112 $.xml(t,a,o,function(h){
113 var h = h.responseText;
114 self.html(h).find("script").each(function(){
116 eval( this.text || this.textContent || this.innerHTML );