Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

allow ajax parameters to be created by a callback function

  • Loading branch information...
commit 1d7419d20a95605be1734096f3836bc7c99af71d 1 parent 1c4dc0b
@juzna authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/prototype/ajax/request.js
View
7 src/prototype/ajax/request.js
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.