#600 ✓duplicate
Serge Ivanchenko

Make JSON implementation JSON2 compliant

Reported by Serge Ivanchenko | March 17th, 2009 @ 08:57 PM

Line 1272: for (var name in headers) Line 1273: this.transport.setRequestHeader(name, headers[name]);

The last "name" value in this iteration is "toJSONString" which is an injected function. So, XMLHttpRequest.setRequestHeader throws an exception.

Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.setRequestHeader]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://xxxx/js/prototype.js :: anonymous :: line 1273" data: no], undefined)prototype.js (line 1140)

Workaround:

for (var name in headers)
    if (typeof headers[name] == 'string')
    this.transport.setRequestHeader(name, headers[name]);

Comments and changes to this ticket

  • Serge Ivanchenko
  • Tobie Langel

    Tobie Langel March 17th, 2009 @ 10:04 PM

    • Tag cleared.
    • State changed from “new” to “enhancement”
    • Assigned user set to “Tobie Langel”
    • Title changed from “v 1.6.0.2 Ajax.Request doesn't work on the latest FF, Chrome and Safari if json.js is included” to “Make JSON implementation JSON2 compliant”

    That's a known issue. We're planning to shift to native JSON support in our future 1.7 release.

    Unfortunately, our implementation of JSON was based on Douglas Crockford's initial one[1], which used different semantics altogether. It turns out that the steps we took back then to avoid naming collisions (using the toJSON method named rather than toJSONString which Doug's initial implementation used) have turned against us. So defaulting to the native implementation might cause some small backward-compatibility issues for some of our users, hence the wait for a more important release.

    [1] http://json.org/json.js

  • Tobie Langel

    Tobie Langel March 17th, 2009 @ 10:05 PM

    Oh, it looks like you are using JSON 1. This has been deprecated in favor of JSON 2.

  • Tobie Langel

    Tobie Langel July 23rd, 2009 @ 02:36 AM

    • State changed from “enhancement” to “duplicate”

    Prototype 1.7 will delegate JSON handling to Douglas Crockford's latest JSON implementation (which is part of ES5 spec draft).

    I'm therefore closing all JSON-related tickets as duplicates of #453. Thanks for your understanding.

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

Attachments

Pages