Skip to main content

Bug Tracker

Side navigation

#2806 closed feature (fixed)

Opened May 06, 2008 12:54PM UTC

Closed May 06, 2008 10:22PM UTC

Last modified March 14, 2012 09:37PM UTC

$.ajax: support for dynamic data arguments

Reported by: joern Owned by: joern
Priority: major Milestone: 1.2.4
Component: ajax Version: 1.2.3
Keywords: ajax dynamic data Cc:
Blocked by: Blocking:
Description

A lot of plugins leverage $.ajax internally. The need to pass through additional parameters from the user comes up very often (eg. autocomplete, treeview, validation). Those parameters must be calculated at request time, eg. a value from an input field.

So far plugins have to evaluate functions before passing them trough to $.ajax. If $.ajax would do that, every ajaxified plugin could leverage that without all the hazzle.

Attachments (2)
Change History (6)

Changed May 06, 2008 01:40PM UTC by flesler comment:1

Could you show a little example ?

Changed May 06, 2008 03:08PM UTC by joern comment:2

Usage in the autocomplete plugin:

function state() {
  return $("#state").val();
}
$(...).autocomplete("county.php", {
  extraParams: {
    "state": state
  }
});

Part of the implemenetation:

var extraParams = {
	timestamp: +new Date()
};
$.each(options.extraParams, function(key, param) {
	extraParams[key] = typeof param == "function" ? param() : param;
});

Changed May 06, 2008 03:17PM UTC by joern comment:3

Implemenetation, if the feature would be added to core, would just pass through extraParams to $.ajax instead of "parsing" it itself.

Changed May 06, 2008 03:23PM UTC by joern comment:4

While this isn't of much use for direct usage with $.ajax, it makes sense for $.ajaxSetup, which you call at some point before starting a request.

Changed May 06, 2008 07:32PM UTC by scott.gonzal comment:5

Having the same parsing for the actual data parameter would be useful too.

Changed May 06, 2008 10:22PM UTC by joern comment:6

resolution: → fixed
status: newclosed

Fixed in [5478].