jQuery: The Write Less, Do More JavaScript Library

Ticket #1516 (closed enhancement: fixed)

Opened 1 year ago

Last modified 3 months ago

.load - add support for standard key/value pairs string as a parameter

Reported by: pops Assigned to: flesler
Type: enhancement Priority: major
Milestone: 1.3 Component: ajax
Version: 1.1.3 Keywords:
Cc: jeresig@gmail.com Needs: Review

Description

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

load-string.diff (360 bytes) - added by flesler 3 months ago.

Change History

Changed 8 months ago by john

  • owner deleted
  • component changed from core to ajax

Changed 3 months ago by flesler

  • status changed from new to assigned
  • owner set to flesler

Changed 3 months ago by flesler

Changed 3 months ago by flesler

  • status changed from assigned to closed
  • resolution set to fixed
  • milestone changed from 1.1.4 to 1.3

The necessary changes were applied at [5701] and additional tests at [5702].

Thanks.

Note: See TracTickets for help on using tickets.