X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=form%2Fform.js;h=f391fcf1751727893a0a992563db46063fe2b6e2;hb=b2d15586bd7cf3f620793b116b4377b8cfc38c8a;hp=d1a7ba798f5570fb9b57fb0ad1118e5d7272080d;hpb=ce6af8e8894b14c7b2c41b64a097bc49acc73b19;p=jquery.git diff --git a/form/form.js b/form/form.js index d1a7ba7..f391fcf 100644 --- a/form/form.js +++ b/form/form.js @@ -37,7 +37,7 @@ * @param url form action override * @param mth form method override * @return "this" object - * @see ajaxForm(), serialize(), load(), $.xml() + * @see ajaxForm(), serialize(), load(), $.ajax() * @author Mark Constable (markc@renta.net) * @author G. vd Hoven, Mike Alsup, Sam Collett, John Resig */ @@ -52,12 +52,12 @@ $.fn.ajaxSubmit = function(target, post_cb, pre_cb, url, mth) { var mth = mth || f.method || 'POST'; if (target && target.constructor == Function) { - $.xml(mth, url, $.param(this.vars), target); + $.ajax(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) { + $.ajax(mth, url, $.param(this.vars), function(r) { eval(r.responseText); }); } @@ -127,6 +127,19 @@ $.fn.ajaxForm = function(target, post_cb, pre_cb) { }); }; +/* + +$.ajax({ + type: "POST", + url: "foo.cgi", + data: $.param( $("form").formdata() ), + success: function(){}, + error: function(){}, + complete: function(){} +}); + + */ + /** * A simple wrapper function that sits around the .serialize() * method, allowing you to easily extract the data stored within @@ -197,10 +210,8 @@ $.fn.serialize = function() { 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; - + var n = this.name; + if (!n) n = (p == 'OPTGROUP') ? par.parentNode.name : (p == 'SELECT') ? par.name : this.name; if (n == undefined) return; a.push({name: n, value: this.value});