[Seaside] Ajax Callback with Response Code other than 200
jtuchel at objektfabrik.de
jtuchel at objektfabrik.de
Fri Jan 3 07:12:58 UTC 2014
Hi Bob, Hi Johan,
your answers are eye-openers for me. Until you pointed me into the
direction of accessing the response via self requestContext, I was under
the false assumption that you cannot answer Ajax callbacks with return
codes other than 200. This opens a whole new universe for me ;-)
Thanks a lot!
So far I've managed to integrate X-editable perfectly, but am still
looking for a way to replace the edited text with the new input as it
was re-formatted on the server in response to the .editable() call. But
that is more a javascript/jQuery/X-editable problem than a seaside one.
the editable() success function has no effect, and I guess I'll have to
try if complete works any better...
I'll make another handful of attempts before I look at jeditable, which
allows you to submit the in-place-editing result to a local function in
which I could send an ajax call back and do what I need (I think).
Joachim
Am 01.01.14 10:10, schrieb Johan Brichau:
> 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
> <mailto: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
>> <mailto:seaside at lists.squeakfoundation.org>
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
--
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel mailto:jtuchel at objektfabrik.de
Fliederweg 1 http://www.objektfabrik.de
D-71640 Ludwigsburg http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20140103/1f23ae57/attachment.htm
More information about the seaside
mailing list