My first plugin, simple, but may provide some usefulness, and reducing
some confusion with new jQuery users using AJAX calls but still
thinking in non-JSON mode to pass parameters.

(function($) {
  var _inherit = $.param;
  $.param = function(a) { return (a.constructor == String)?
a:_inherit(a); };
})(jQuery);

This overrides jQuery.param() with inheritance to support the passing
of string KV pairs parameters while keeping with backward support for
Object or Array parameters to the AJAX functions; .load, .get, etc.

string: .load(url,"p1=v1&p2=v2.....&pn=vn");
JSON: .load(url,{p1:'v1', p2:'v2' ....,pn:'vn'});

--
HLS

Reply via email to