Problem:
.load(url, parameter) has an obstrusive and ambiguious design of requiring the parameter to be an OBJECT format. If a string is provided, as I believe most new jQuery application developers would assume to use, especially when the documentation those use the phase "(optional) A set of key/value pairs that will be sent as data to the server", then .load will incorrectly sent a strung out string of key/value pairs for each character in the string parameter.
Solution:
.load uses jQuery.param() to convert an Array or JSON Object into KV pairs.
A possible solution is to add String data type detection support in jQuery.param() like so:
if (a.constructor == string) {
// we got what we want, no more transformations required
}
else
if ( a.constructor == Array
a.jquery )
....
This will allow for a more natural and "unobstrusive" design for developers.
NOTE:
If this is considered for implementation, the AJAX request when passing a string parameter SHOULD remain as a GET and not a POST.
Attachments
Change History
Download in other formats:
|