[jQuery] $.ajax() with json output

2006-11-16 Thread Dave Methvin
If you specify json output in the $.ajax call and the resulting output isn't well-formed json for any reason, it causes a javascript error on the eval in $.ajaxData. Has anyone else encountered this? My quick fix was to wrap the eval in a try/catch and return null if there was an error, does that

Re: [jQuery] $.ajax() with json output

2006-11-16 Thread Mike Alsup
On 11/16/06, Dave Methvin [EMAIL PROTECTED] wrote: If you specify json output in the $.ajax call and the resulting output isn't well-formed json for any reason, it causes a javascript error on the eval in $.ajaxData. Has anyone else encountered this? My quick fix was to wrap the eval in a

Re: [jQuery] $.ajax() with json output

2006-11-16 Thread Klaus Hartl
Dave Methvin schrieb: If you specify json output in the $.ajax call and the resulting output isn't well-formed json for any reason, it causes a javascript error on the eval in $.ajaxData. Has anyone else encountered this? My quick fix was to wrap the eval in a try/catch and return null if

Re: [jQuery] $.ajax() with json output

2006-11-16 Thread Christopher Jordan
I may be showing my ignorance here, but why (or maybe more appropriately how) would invalid json code get returned by your ajax call? Shouldn't you just make sure that the data coming back is valid json? Maybe I've not run into this because I'm using Jehiah Czebotar's CFJson (obviously, my

Re: [jQuery] $.ajax() with json output

2006-11-16 Thread Klaus Hartl
Christopher Jordan schrieb: I may be showing my ignorance here, but why (or maybe more appropriately how) would invalid json code get returned by your ajax call? Shouldn't you just make sure that the data coming back is valid json? Maybe I've not run into this because I'm using Jehiah

Re: [jQuery] $.ajax() with json output

2006-11-16 Thread Dave Methvin
I may be showing my ignorance here, but why (or maybe more appropriately how) would invalid json code get returned by your ajax call? Ignorance, no. Lack of WTF imagination, yes. :-) On the server I was testing against, status codes like 404 and 500 are mapped into 200 as a workaround for

Re: [jQuery] $.ajax() with json output

2006-11-16 Thread Ⓙⓐⓚⓔ
I assumed the lack of try catch code is to make jquery lean for the majority... If you are getting garbage from your server add your own try catch around the jquery call. -- Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ ___ jQuery mailing list discuss@jquery.com

Re: [jQuery] $.ajax() with json output

2006-11-16 Thread John Resig
That said, I think it should be as fail-safe as possible. But which is worse - throwing an exception inside of jQuery due to malformed JSON data - or silently dying? I mean, as it stands right now, jQuery assumes that all data coming into it (selectors, arguments, etc.) are well-formed. Beyond