X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fajax.js;h=a9e13a879e2b3e4548ff26dcb7199ff3fef65d8c;hb=7862c45ad2f32096383a21b8b301155787724476;hp=9886fd70f9273cc7736df5ebe0c5c4cb8fb96e40;hpb=515efbdc7119aa79de710144effe18413d4cb14a;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index 9886fd7..a9e13a8 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -542,7 +542,7 @@ jQuery.extend({ }); function buildParams( prefix, obj, traditional, add ) { - if ( jQuery.isArray(obj) ) { + if ( jQuery.isArray(obj) && obj.length ) { // Serialize array item. jQuery.each( obj, function( i, v ) { if ( traditional || rbracket.test( prefix ) ) { @@ -562,10 +562,15 @@ function buildParams( prefix, obj, traditional, add ) { }); } else if ( !traditional && obj != null && typeof obj === "object" ) { + if ( jQuery.isEmptyObject( obj ) ) { + add( prefix, "" ); + // Serialize object item. - jQuery.each( obj, function( k, v ) { - buildParams( prefix + "[" + k + "]", v, traditional, add ); - }); + } else { + jQuery.each( obj, function( k, v ) { + buildParams( prefix + "[" + k + "]", v, traditional, add ); + }); + } } else { // Serialize scalar item.