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

Ticket #9173 (closed defect: wontfix)

Opened 2 years ago

Last modified 2 years ago

Ajax request header problem if javascript object prototype has been extended.

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

Description

If you use both prototype.js and another script which add fonction to the object prototype definition, you get an exception with FireFox.

[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.setRequestHeader]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://www.mydomain.com/Javascripts/prototype.js :: anonymous :: line 1104" data: no]

for exemple if you have a script that contain :

function (){

var cryptfunction={

object: function(obj){ //code of the function ....... }

}

Object.prototype.MyCryptFunction = function () {

return cryptfunction.object(this); }

}

Then Ajax.Request() function will handle an exception because of trying to add MyCryptFunction to the headers of the XMLHTTPRequest object.

To solve the problem :

in prototype.js v 1.5.1

just replace

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

by

1103 for (var name in headers){ 1104 if (typeof(headers[name])=="string") 1105 this.transport.setRequestHeader(name, headers[name]); 1106 }

Change History

08/03/07 08:19:29 changed by Tobie

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

This has been brought up numeroud times already. I'm sorry, but we won't fix this. Extending Object.prototype is verboten.

Closing as wontfix.