I think you will have to use the *fail* deferred callback method when
dealing with non-200 responses.

Ex:
$.post (url, params).done(function (response) {
     // Normal response data
})
.fail(function (response) {
     alert (response.somedata); // Alert -> "some data"
});

On Fri, May 8, 2015 at 6:57 PM, Mário Idival <[email protected]> wrote:

>
> http://docs.pylonsproject.org/docs/pyramid/en/latest/api/httpexceptions.html#pyramid.httpexceptions.exception_response
>
> Mário Idival
> Python Developer
>
> *Twitter|Github|Skype *: *marioidival*
> *Facebook*: *mario.idival*
> *User Linux** : **#554446*
>
> 2015-05-08 14:58 GMT-03:00 Vincent Catalano <[email protected]>:
>
> I'm a little confused be what you mean when you say "exception_response".
>> Have you considered using Exception Views
>> http://pyramid-cookbook.readthedocs.org/en/latest/pylons/exceptions.html#exception-views?
>> The primary difference would be that you would want to return a 200 status
>> code instead of 500 so that jQuery will appropriately handle your response
>> like you want.
>>
>> On Thu, May 7, 2015 at 6:51 PM, Mário Idival <[email protected]>
>> wrote:
>>
>>> Hello Everyone,
>>>
>>> How can I return a value through the exception_response.
>>>
>>> Ex ->
>>> with jQuery usually we have this kind of code:
>>> // frontend
>>> $.post (url, params).done(function (response) {
>>>      alert (response.somedata); // Alert -> "some data"
>>> });
>>>
>>> #backend
>>>
>>> view_config (route_name = "someview" renderer = "json")
>>> def someview (request):
>>>     # Do something
>>>     {return "somedata": "some data"}
>>>
>>>
>>> How I can do that, using execption_response?
>>>
>>> execption_response(200, somedata="some data")
>>>
>>> ??
>>> Mário Idival
>>> Python Developer
>>>
>>> *Twitter|Github|Skype *: *marioidival*
>>> *Facebook*: *mario.idival*
>>> *User Linux** : **#554446*
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "pylons-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/pylons-discuss.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Vincent Catalano
>> Software Engineer and Web Developer,
>> (520).603.8944
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "pylons-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/pylons-discuss.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/pylons-discuss.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Vincent Catalano
Software Engineer and Web Developer,
(520).603.8944

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to