Question about 'param' method
// 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 || a.jquery ) {
// 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 ) {
// If the value is an array then the key names need to
be repeated
if( a[j].constructor == Array ) {
for (var k = 0; k < a[j].length; k++) {
s.push( j + "=" + encodeURIComponent( a[j][k] ) );
}
} else {
s.push( j + "=" + encodeURIComponent( a[j] ) );
}
}
}
// Return the resulting serialization
return s.join("&");
}
If a form has a lot of checkboxes with name="selectedVal[]" the 'param'
method will return something like:
selectedVal=1&selectedVal=2&selectedVal=3
I use PHP on server side and the post/get var will count only the last
selectVal and will not be an array.
Some time ago i changed
s.push( j + "=" + encodeURIComponent( a[j][k] ) );
into
s.push( j + "[]=" + encodeURIComponent( a[j][k] ) );
and worked fine, for me at least.
Can we do something about it?
_______________________________________________
Jquery-dev mailing list
Jquery-dev@bassistance.de
http://lists.bassistance.de/mailman/listinfo/jquery-dev