[Seaside] Responding to Ajax call with JSON
Philippe Marschall
philippe.marschall at gmail.com
Wed Jan 1 15:01:04 UTC 2014
On Tue, Dec 31, 2013 at 2:40 PM, jtuchel at objektfabrik.de
<jtuchel at objektfabrik.de> wrote:
> Hi There,
>
> I wonder how I could write an Ajax callback that returns an HTTP 200
> response code and a JSOn document as response contents. I am unable to find
> any samples for this.
I see what you're trying to do there, you're trying to get these in
before Monday ;-)
As others have noted before #respond: gives you full access to the
response allowing you to set any header or content you like:
html submitButton
onClick: (html jQuery ajax
respond: [ :response |
response
created; "HTTP 201"
doNotCache;
contentType: WAMimeType applicationJson.
response stream nextPutAll: '{"jsonrpc": "2.0", "result":
19, "id": 1}' ]);
with: 'Replace'
Cheers
Philippe
More information about the seaside
mailing list