I listed an actual example above.
user description as stored in mysql - 'I\'ll take you down to china
town'
when I parse the json object the slash is removed, so I print -
onclick="function('I'll take you down to china town')"
which throws an error.
On Oct 9, 5:04 pm, "T.J. Crowder" <[EMAIL PROTECTED]> wrote:
> > personally, I would consider this a serious drawback to using json - as
> > opposed to xml, which does not display this behavior.
>
> It's not a JSON thing, it's something specific to what you're doing.
>
> Can you give us an example of the actual JSON data you're returning
> from the server?
> --
> T.J. Crowder
> tj / crowder software / com
>
> On Oct 9, 9:21 pm, "suki rosen" <[EMAIL PROTECTED]> wrote:
>
> > personally, I would consider this a serious drawback to using json - as
> > opposed to xml, which does not display this behavior. I'm really hoping
> > there's a workaround here, but I feel like I may drop prototype in favor of
> > a library that has better xml support.
>
> > > On Thu, Oct 9, 2008 at 3:53 PM, Hector Virgen <[EMAIL PROTECTED]> wrote:
>
> > >> Is there a reason you need the data to remain escaped while being used by
> > >> javascript? Unless your javascript is interacting directly with the
> > >> database, you should not need to keep your data escaped. Once javascript
> > >> is
> > >> done with the data, and sends it back to the server, the server should
> > >> then
> > >> re-escape the unescaped data before inserting into the database.
> > >> -Hector
>
> > >> On Thu, Oct 9, 2008 at 11:22 AM, pancakes <[EMAIL PROTECTED]> wrote:
>
> > >>> Hi.
> > >>> I'm using prototype for my ajax routines. I'm returning a json object
> > >>> from the server containing user information. Some of the information
> > >>> contains user descriptions with quotes and other weird characters that
> > >>> need to be escaped.
>
> > >>> for example
> > >>> 'I'm going to the store, don't 'cha know?'
> > >>> is stored in my db as
> > >>> 'I\'m going to the store, don\'t \'cha know?'
>
> > >>> but when I get my json object back from the server, I need to eval()
> > >>> it. This strips the slashes. I tried prototype's built in json parser
> > >>> next (evalJSON();) with the same results.
>
> > >>> Is there any way to preserve my escape characters and use json for
> > >>> data structuring??
>
> > >>> I am aware that javascript has find/replace functions, but trusting
> > >>> the escaping of problem characters to the browser doesn't appeal to
> > >>> me. I want to escape the data on the server. also, this needs to
> > >>> work for single or double quotes, as these are user input and I want
> > >>> it to work regardless of the data.
>
> > >>> thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---