- if (!ok[this.nodeName.toUpperCase()])
- return;
-
- var par = this.parentNode;
- var p = par.nodeName.toUpperCase();
- if ((p == 'SELECT' || p == 'OPTGROUP') && !this.selected)
- return;
-
- var n = this.name || par.name;
- if (!n && p == 'OPTGROUP' && (par = par.parentNode))
- n = par.name;
-
- if (n == undefined)
- return;
-
- a.push({name: n, value: this.value});
- });
-
- this.vars = a;
-
- return this;
-}
-
-/**
- * Final form submission plugin usually used in conjunction with
- * form() and getForm(). If a second argument is a valid function
- * then it will be called before the form vars are sent to the
- * backend. If this pre-submit function returns exactly "false"
- * then it will abort further processing otherwise the process
- * will continue according to the first and third arguments.
- *
- * If the first argument is a function, and it exists, then the form
- * values will be submitted and that callback function called. If
- * the first argument is a string value then the "load()" plugin
- * will be called which will populate the innerHTML of the indicated
- * element and a callback will be called if there is third argument.
- * If there are no arguments then the form values are submitted with
- * an additional variable (evaljs=1) which indicates to the backend
- * to to prepare the returned results for evaluation, ie; the result
- * needs to be valid javascript all on a single line.
- *
- * Usage example:
- *
- * $.fn.myvars = function() {
- * this.vars = [];
- * for (var i in this) {
- * if (this[i] instanceof Function || this[i] == null) continue;
- * this.vars.push({name: i, value: this[i].length});
- * }
- * return this;
- * }
- *
- * precb = function(vars) {
- * return confirm('Submit these values?\n\n'+$.param(vars));
- * }
- *
- * $('*').myvars().putForm('#mytarget',precb,null,'myhandler.php');
- *
- * @param target arg for the target id element to render
- * @param pre_cb callback function before submission
- * @param post_cb callback after any results are returned
- * @param url form action override
- * @param mth form method override
- * @return "this" object
- * @see form(), getForm(), load(), xml()
- * @author Mark Constable (markc@renta.net)
- * @author G. vd Hoven, Mike Alsup, Sam Collett
- * @version 20060606
- */
-$.fn.putForm = function(target, pre_cb, post_cb, url, mth) {
- if (pre_cb && pre_cb.constructor == Function)
- if (pre_cb(this.vars) === false)
- return;
-
- var f = this.get(0);
- var url = url || f.action || '';
- var mth = mth || f.method || 'POST';
-
- if (target && target.constructor == Function) {
- $.xml(mth, url, $.param(this.vars), target);
- } else if (target && target.constructor == String) {
- $(target).load(url, this.vars, post_cb);
- } else {
- this.vars.push({name: 'evaljs', value: 1});
- $.xml(mth, url, $.param(this.vars), function(r) { eval(r.responseText); });
+ // Stop memory leaks
+ xml.onreadystatechange = function(){};
+ xml = null;
+ }
+ };
+
+ // Send the data
+ xml.send(data);
+ },
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Determines if an XMLHttpRequest was successful or not
+ httpSuccess: function(r) {
+ try {
+ return r.status ?
+ ( r.status >= 200 && r.status < 300 ) || r.status == 304 :
+ location.protocol == "file:";
+ } catch(e){}
+ return false;
+ },
+
+ // Get the data out of an XMLHttpRequest.
+ // Return parsed XML if content-type header is "xml" and type is "xml" or omitted,
+ // otherwise return plain text.
+ httpData: function(r,type) {
+ var ct = r.getResponseHeader("content-type");
+ var xml = ( !type || type == "xml" ) && ct && ct.indexOf("xml") >= 0;
+ return xml ? r.responseXML : r.responseText;
+ },
+
+ // Serialize an array of form elements or a set of
+ // key/values into a query string
+ param: function(a) {
+ var s = [];
+
+ // If an array was passed in, assume that it is an array
+ // of form elements
+ if ( a.constructor == Array )
+ // Serialize the form elements
+ for ( var i = 0; i < a.length; i++ )
+ s.push( a[i].name + "=" + encodeURIComponent( a[i].value ) );
+
+ // Otherwise, assume that it's an object of key/value pairs
+ else
+ // Serialize the key/values
+ for ( var j in a )
+ s.push( j + "=" + encodeURIComponent( a[j] ) );
+
+ // Return the resulting serialization
+ return s.join("&");