Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7882 (closed defect: duplicate)

Opened 2 years ago

Last modified 2 years ago

toQueryString removes empty parameters

Reported by: bokuhog Assigned to: sam
Priority: normal Milestone: 1.x
Component: Prototype Version: edge
Severity: normal Keywords:
Cc:

Description

version used: 1.5.1_rc2

Repro:
Make a Ajax request and set parameters to string like so...

var pars = "term=&active=Yes&type=Regular";

var tmp = new Ajax.Request(
            url, 
            {   method: 'post', 
                parameters: pars,
                onSuccess: this.saveXml.bind(this),
                onFailure: onError  
            });

When the request is actually made the params look like this:

"active=Yes&type=Regular" 

(term is missing)

This behavior did not exist in 1.5.0

Was able to resolve the problem by removing line 793

original:

Hash.toQueryString.addPair = function(key, value, prefix) {
  if (value == null) return;
  key = encodeURIComponent(key);
  this.push(key + '=' + (value == null ? '' : encodeURIComponent(value)));
}

modified:

Hash.toQueryString.addPair = function(key, value, prefix) {
  key = encodeURIComponent(key);
  this.push(key + '=' + (value == null ? '' : encodeURIComponent(value)));
}

Change History

03/21/07 19:15:49 changed by bokuhog

  • owner changed from core to sam.
  • component changed from ActiveRecord to Prototype.

03/21/07 19:26:24 changed by bokuhog

  • status changed from new to closed.
  • resolution set to duplicate.

03/21/07 19:27:03 changed by bokuhog

duplicate of
* Ticket #7806