Unexpected characters when using Prototype (AJAX)
A little while back someone pointed me at the weird behaviour of my preview box when adding a comment. Somehow &_= was added to the end of the preview content.
It took me quite some time to figure out where it was coming from. I searched and searched, but couldn’t find the problem. I thought it wouldn’t be a Prototype bug, since Rails had been updated, but Prototype hadn’t changed.
So I asked around in #rubyonrails and Thomas Fuchs pointed me in the right direction.
It seemed changeset 2106 in Rails changed the way a Safari bug was tackled. It had been the case that Prototype added the &_= to the end of the POST data and ActionPack would strip this away again. But since another fix was found for this problem, there was no need for the &_= anymore.
So the following (line 213, or in the latest Edge Rails version line 476) should be removed from prototype.js:
if (parameters.length > 0) parameters += '&_=';
I had already discovered that removing the line fixed the problem, but it was good to find the reason why. And I’ve filed it as ticket 2258.
James on 4 January 2006 at 11:31.
Thank you. Thank you. Thank you.
It took me forever to figure out that the “&_=” was being passed – and a google search led me here. Then I removed the line from prototype.js and all is well.