Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / November 2006



Tip: Looking for answers? Try searching our database.

JavaScript JSON stringifier

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gerry Vandermaesen - 30 Nov 2006 09:16 GMT
Hi,

Does anyone have a freely available JavaScript JSON stringifier. So far
my search has been in vain, the one offered on
http://www.json.org/json.js does not seem to work for me.
Gerry Vandermaesen - 30 Nov 2006 11:24 GMT
I looked into the original problem and noticed the following:

As soon as I extend the Object.prototype with another function
(toJSONString in this case), my Ajax.Request fails in Firefox only.

Example:

Object.prototype.toJSONString = function() {
    return true;
}
new Ajax.Request(
    "http://www.example.com",
    {
        onComplete: function() {
            alert('complete')
        }
    }
);

On Internet Explorer this works, but on Firefox this will fail, and I
don't get the 'complete' alert. Any ideas on the reason and how to
solve this?

> Hi,
>
> Does anyone have a freely available JavaScript JSON stringifier. So far
> my search has been in vain, the one offered on
> http://www.json.org/json.js does not seem to work for me.
Richard Cornford - 30 Nov 2006 12:22 GMT
> I looked into the original problem and noticed the following:
>
[quoted text clipped - 18 lines]
> don't get the 'complete' alert. Any ideas on the reason and how to
> solve this?

This is - Ajax.Request - from Prototype.js? As Prototype.js is not
ECMAScript compatible (relies entirely on implementation decisions not
to throw exceptions where exceptions may be thrown) it is not likely to
behave consistently across ECMA 262, 3rd Ed. implementations. Seeing
that happen is not unexpected.

If you want an analysis of the cause and effect relationships that are
happening here you will need to provide a minimal text-case that
demonstrates the issue (in isolation from everything that is
irrelevant)  rather than a non-testable fragment code.

Richard.
Gerry Vandermaesen - 30 Nov 2006 12:55 GMT
Yes, I do use an unmodified prototype.js for the AJAX request.

I set up an example at http://www.allyourbase.be/test/index.html

The example will act as expected under IE7, but does not throw the
alert under Firefox (using 2.0).

> > I looked into the original problem and noticed the following:
> >
[quoted text clipped - 31 lines]
>
> Richard.
Gerry Vandermaesen - 30 Nov 2006 13:10 GMT
I also noted this problem only occurs with prototype version 1.5.0_rc1,
which is shipped with and required by the script.aculo.us libraries.
When using prototype 1.4.0 I didn't have a problem. However, we do make
use of the script.aculo.us libraries too on our site.

> Yes, I do use an unmodified prototype.js for the AJAX request.
>
[quoted text clipped - 38 lines]
> >
> > Richard.
Fred - 30 Nov 2006 14:10 GMT
> I also noted this problem only occurs with prototype version 1.5.0_rc1,
> which is shipped with and required by the script.aculo.us libraries.
> When using prototype 1.4.0 I didn't have a problem. However, we do make
> use of the script.aculo.us libraries too on our site.

Then you will have to deal with that.  An old version of json.js used a
JSON object with two methods rather than extending built-in objects,
search for "JSON serialization" at:

news:rubyonrails-spinoffs

<URL: http://groups.google.com.au/group/rubyonrails-spinoffs >

Signature

Fred

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.