Here's the source code in Request.JSON:

success: function(text){

                var secure = this.options.secure;

                var json = this.response.json = Function.attempt(function(){

                        return JSON.decode(text, secure);

                });


                if (json == null) this.onFailure();

                else this.onSuccess(json, text);

        }

It is calling JSON.decode on the response for you. If you don't return
valid JSON, it won't call onSuccess, but instead consider it a failure




On Thu, Dec 16, 2010 at 9:16 AM, brook <[email protected]> wrote:

> Hey Guys - Its been awhile hope everyone is well...
>
> Unless I am making some mistake it seems  onSuccess in Request.JSON
> only returns a string.
> I am assuming the point is that you now use JSON.decode on that string
> so there is no longer a need for it to return the responseJSON.
>
> If I am right this is just a heads up that the DOCS page still says it
> returns a json object.
>
> If I am wrong is there something I might be doing that to causing it
> not to return the object  (i am happy with the string - but i was just
> curious)? I saw there was just post about how malformed json docs will
> never call the onSuccess function... could it be something like this?
>
> Thanks. An Early happy new years to all. cheers cheers.b

Reply via email to