diff options
author | Sam Stephenson <sam@37signals.com> | 2005-06-27 06:33:09 +0000 |
---|---|---|
committer | Sam Stephenson <sam@37signals.com> | 2005-06-27 06:33:09 +0000 |
commit | 0dd2981d2b966b97a5ab869f712d7fb7bc1c3598 (patch) | |
tree | ce5a6ca57ffb33072375e81007d177ee440a2922 | |
parent | 2269c23699968d31f2f81052ebcf7fcc29e82502 (diff) | |
download | rails-0dd2981d2b966b97a5ab869f712d7fb7bc1c3598.tar.gz rails-0dd2981d2b966b97a5ab869f712d7fb7bc1c3598.tar.bz2 rails-0dd2981d2b966b97a5ab869f712d7fb7bc1c3598.zip |
Fix a potential bug in Prototype's Ajax.Request involving Mozilla and null POST bodies
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1534 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/lib/action_view/helpers/javascripts/prototype.js | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/actionpack/lib/action_view/helpers/javascripts/prototype.js b/actionpack/lib/action_view/helpers/javascripts/prototype.js index f400511ba7..72551c8a55 100644 --- a/actionpack/lib/action_view/helpers/javascripts/prototype.js +++ b/actionpack/lib/action_view/helpers/javascripts/prototype.js @@ -184,27 +184,27 @@ Ajax.Request.prototype = (new Ajax.Base()).extend({ initialize: function(url, options) { this.transport = Ajax.getTransport(); this.setOptions(options); - + + var parameters = this.options.parameters || ''; + if (parameters.length > 0) parameters += '&_='; + try { if (this.options.method == 'get') - url += '?' + this.options.parameters + '&_='; - + url += '?' + parameters; + this.transport.open(this.options.method, url, this.options.asynchronous); - + if (this.options.asynchronous) { this.transport.onreadystatechange = this.onStateChange.bind(this); setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10); } - + this.setRequestHeaders(); - var sendData = this.options.postBody ? this.options.postBody - : this.options.parameters ? this.options.parameters + '&_=' - : null; + var body = this.options.postBody ? this.options.postBody : parameters; + this.transport.send(this.options.method == 'post' ? body : null); - this.transport.send(this.options.method == 'post' ? sendData : null); - } catch (e) { } }, @@ -221,7 +221,7 @@ Ajax.Request.prototype = (new Ajax.Base()).extend({ requestHeaders.push.apply(requestHeaders, this.options.requestHeaders); for (var i = 0; i < requestHeaders.length; i += 2) - this.transport.setRequestHeader(requestHeader[i], requestHeader[i+1]); + this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]); }, onStateChange: function() { |