[Seaside] Ajax Callback with Response Code other than 200

Johan Brichau johan at inceptive.be
Wed Jan 1 09:10:35 UTC 2014


Indeed.

There is a bit of doc on this here: http://book.seaside.st/book/advanced/restful/request-response
Although it’s in the context of REST, the #respond: method can be invoked in any request context (hence “self requestContext respond: [:response | … ]) to take low-level control on what Seaside should respond.
 And there are methods on WAResponse to set the status code.

Cheers and happy new year!
Johan

On 31 Dec 2013, at 20:43, Bob Arning <arning315 at comcast.net> wrote:

> Well, just trying things a bit, this seems to work:
> 
> "===================="
>     html div
>         onClick: (html jQuery ajax 
>             callback: [ :val |
>                 val inspect.
>                 self requestContext respond: [ :response |
>                     response 
>                         contentType: 'text/json' seasideMimeType;
>                         nextPutAll: {'what arrived was'. val} asJson
>                     ]
>                 ]
>             value: (JSStream on: 'this.innerHTML')
>         );
>         with: 't2'.
> "===================="
> 
> Cheers,
> Bob
> 
> On 12/31/13 9:30 AM, jtuchel at objektfabrik.de wrote:
>> Hi again, 
>> 
>> thinking a bit more about my X-editable plans, I dug a bit deeper into JQAjax. Unfortunately, this gives me more questions than answers ;-) 
>> 
>> Say I have an ajax callback using jquery like this: 
>> 
>> html anchor 
>> id: 'mylink'; 
>> onClick: (html jQuery  ajax callback: [self doSomething]); 
>> with: 'Click here'. 
>> 
>> 
>> This callback will always respond with an empty HTTP response with status code 200, right? 
>> There are other callback methods on JQAjax, like respond:, text: and so on. 
>> 
>> Is there any documentation on these? 
>> 
>> I am looking for a way to transport some value to a server-side callback block and respond with one of these two options: 
>> 
>> a) HTTP 200 and a JSON document with success information and probably an error message 
>> b) HTTP 200 if the callback processed without errors, or a different HTTP code and some error text in the response's body if there is some error during processing the callback 
>> 
>> Has anybody done this? Any pointers to more details? 
>> 
>> Thanks in advance and happy new year to all Seasiders! 
>> 
>> Joachim 
>> 
>> 
> 
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20140101/539b812d/attachment-0001.htm


More information about the seaside mailing list