Skip to content

Commit

Permalink
allow ajax parameters to be created by a callback function
Browse files Browse the repository at this point in the history
  • Loading branch information
juzna committed Jan 13, 2011
1 parent 1c4dc0b commit 1d7419d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/prototype/ajax/request.js
Expand Up @@ -180,9 +180,10 @@ Ajax.Request = Class.create(Ajax.Base, {
this.timeStart = (new Date).getTime(); // Measure time of requests
this.url = url;
this.method = this.options.method;
var params = Object.isString(this.options.parameters) ?
this.options.parameters :
Object.toQueryString(this.options.parameters);
var params = this.options.parameters;
if(Object.isFunction(params)) params = params(this); // Parameters given as callback
else if(Object.isFunction(params.toObject)) params = params.toObject(params, this); // Explicit convertor for parameters
if(!Object.isString(params)) params = Object.toQueryString(params);

if (!['get', 'post'].include(this.method)) {
// simulate other verbs over post
Expand Down

0 comments on commit 1d7419d

Please sign in to comment.