#1151 new

Cannot use Ajax.Request in Google's Chrome.

Reported by Ania | October 1st, 2010 @ 10:47 PM

We have been using prototype.js (currently on version in FF/IE successfully for number of years. Recently I tried to bring up our UI in Google's Chrome - unsuccessfully.

After much debugging on both back-end (was generating servlet errors complaining about "UTF-8,") and client, finally I found the issue.

In prototype there is a hash build 'headers' in preparation for ajax request. One of the entries in this hash is "Content-type" as in "headers['Content-type']. Please notice the lower case "t" in "type"! What happens then is, when the request is being prepared it will ultimately call Ajax.Request.setRequestHeaders() function. In that function, at the very bottom the headers are set in XMLHttpRequest object:

line 1272:

for (var name in headers)
  this.transport.setRequestHeader(name, headers[name]);

at that point, hash 'headers' has two (2!!) entries:

Content-Type "application/xml"
Content-type "application/x-www-form-urlencoded; charset=UTF-8" //(lower 't')

No idea what guides in which order the iteration takes place, but I see that in both FF and Chrome 'Content-type' goes first. I can only assume that in Chrome when subsequently "Content-Type" (capital "T") is being set, it gets ignored.

Changing the 'Content-type' (lower case "t" in "type") to "Content-Type" (capital "T" in "Type") throughout prototype.js (3 occurrences) solves the issue and code continues to work correctly in FF/IE and, finally, in Chrome.

The manifestation of this problem were exceptions on the backend as the content type was coming in as "application/x-www-form-urlencoded; charset=UTF-8" and subsequent parsing created encoding type of "UTF-8," (notice the extra comma ",").

I just downloaded the latest "stable" version, 1.6.1 and see that same issue still exists there.

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket