+ * This method attempts to mimic the functionality of the original form\r
+ * as best as possible (duplicating the method, action, and exact contents\r
+ * of the form).\r
+ *\r
+ * There are three different resulting operations that can occur, after\r
+ * your form has been submitted.\r
+ *\r
+ * 1. The form is submitted and a callback is fired, letting you know\r
+ * when it's done:\r
+ * $("form").ajaxSubmit(function(){\r
+ * alert("all done!");\r
+ * });\r
+ *\r
+ * 2. The form is submitted and the resulting HTML contents are injected\r
+ * into the page, at your specified location.\r
+ * $("form").ajaxSubmit("#destination");\r
+ *\r
+ * 3. The form is submitted and the results returned from the server are\r
+ * automatically executed (useful for having the server return more\r
+ * Javascript commands to execute).\r
+ * $("form").ajaxSubmit();\r
+ *\r
+ * Additionally, an optional pre-submit callback can be provided. If it,\r
+ * when called with the contents of the form, returns false, the form will\r
+ * not be submitted.\r
+ *\r
+ * Finally, both the URL and method of the form submission can be\r
+ * overidden using the 'url' and 'mth' arguments.\r
+ *\r
+ * @param target arg for the target id element to render\r
+ * @param post_cb callback after any results are returned\r
+ * @param pre_cb callback function before submission\r
+ * @param url form action override\r
+ * @param mth form method override\r
+ * @return "this" object\r
+ * @see ajaxForm(), serialize(), load(), $.xml()\r
+ * @author Mark Constable (markc@renta.net)\r
+ * @author G. vd Hoven, Mike Alsup, Sam Collett, John Resig\r
+ */\r
+$.fn.ajaxSubmit = function(target, post_cb, pre_cb, url, mth) {\r
+ if ( !this.vars ) this.serialize();\r
+ \r
+ if (pre_cb && pre_cb.constructor == Function)\r
+ if (pre_cb(this.vars) === false) return;\r
+\r
+ var f = this.get(0);\r
+ var url = url || f.action || '';\r
+ var mth = mth || f.method || 'POST';\r
+\r
+ if (target && target.constructor == Function) {\r
+ $.xml(mth, url, $.param(this.vars), target);\r
+ } else if (target && target.constructor == String) {\r
+ $(target).load(url, this.vars, post_cb);\r
+ } else {\r
+ this.vars.push({name: 'evaljs', value: 1});\r
+ $.xml(mth, url, $.param(this.vars), function(r) {\r
+ eval(r.responseText);\r
+ });\r
+ }\r
+\r
+ return this;\r
+};\r
+\r
+/**\r
+ * This function can be used to turn any HTML form into a form\r
+ * that submits using AJAX only.\r
+ *\r
+ * The purpose of using this method, instead of the ajaxSubmit()\r
+ * and submit() methods, is to make absolutely sure that the\r
+ * coordinates of <input type="image"/> elements are transmitted\r
+ * correctly OR figuring out exactly which <input type="submit"/>\r
+ * element was clicked to submit the form.\r
+ *\r
+ * If neither of the above points are important to you, then you'll\r
+ * probably just want to stick with the simpler ajaxSubmit() function.\r
+ *\r
+ * Usage examples, similar to ajaxSubmit():\r