Thanks again Michael!

I changed that particular line to use eval() and it works just the
same... saved me an external js with 50 lines or so, great stuff! :)

Thanks for the svn link too, I doubt I'll be using it regularly but
always good to know what's cooking!

On Sep 9, 12:57 am, Michael Geary <m...@mg.to> wrote:
> Glad to help, Alex.
>
> Some people say eval() is evil, but it isn't. Like any powerful tool, it has
> certain characteristics that can be good or bad, depending.
>
> The 1.3.3-style code is certainly better, using either JSON.parse if it's
> available or else the Function constructor. The Function constructor is
> basically just another flavor of eval(), but by chance it happens that
> eval() can be rather slow if Firebug is running, but the Function
> constructor doesn't slow down the same way.
>
> I don't know when 1.3.3 will be released, but you can always check out the
> code from Subversion if you want to see the very latest:
>
> http://jqueryjs.googlecode.com/svn/trunk
>
> Or if you want *all* the tagged versions:
>
> http://jqueryjs.googlecode.com/svn
>
> -Mike
>
> On Tue, Sep 8, 2009 at 6:39 PM, Alex Weber <alexwebe...@gmail.com> wrote:
>
> > Thanks for that Michael!
>
> > I guess I've heard so many eval() horror stories that I automatically
> > decided against it...
>
> > BTW what's this 1.3.3 talk? I thought it was supposed to be released
> > last month? ;)
>
> > Alex
>
> > On Sep 8, 5:11 am, Michael Geary <m...@mg.to> wrote:
> > > Why do you not want to use eval()? That's what jQuery 1.3.2 does in
> > > $.getJSON and $.ajax:
>
> > >             // Get the JavaScript object, if JSON is used.
> > >             if ( type == "json" )
> > >                 data = window["eval"]("(" + data + ")");
>
> > > Or better, you can use this code from jQuery 1.3.3:
>
> > >             // Get the JavaScript object, if JSON is used.
> > >             if ( type === "json" ) {
> > >                 if ( typeof JSON === "object" && JSON.parse ) {
> > >                     data = JSON.parse( data );
> > >                 } else {
> > >                     data = (new Function("return " + data))();
> > >                 }
> > >             }
>
> > > -Mike
>
> > > On Mon, Sep 7, 2009 at 11:02 PM, Alex Weber <alexwebe...@gmail.com>
> > wrote:
>
> > > > I use $.getJSON for all my ajax stuff and it works beautifully but
> > > > there is one particular situation where I use an iframe hack to do an
> > > > ajax file upload and even though the returned value is a json object
> > > > (created with PHP), jQuery treats it like a string.
>
> > > > I'm using json2.js right now and it does the trick but I don't like
> > > > including that much extra code because of one rare situation.
>
> > > > So my question is, be it with $.getJSON or by specifying 'json' as the
> > > > expected return type of an ajax request, jQuery *seems* to be able to
> > > > convert into json.
>
> > > > The string returned is already a json object, I just need jQuery to be
> > > > able to treat it like one.  I've tried wrapping it in a jQuery object
> > > > but no use.  (and I really don't want to go down the eval() path)...
>
> > > > Any suggestions?
>
> > > > Thanks!!

Reply via email to