Return document attachment from AJAX callback

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Return document attachment from AJAX callback

Esteban A. Maringolo
Is it possible to return a document attachment as a response of an ajax
call?

I'm currently returning a file as part of a regular action callback
associated with an anchor, but as most of the app is AJAX driven, it
would be convenient to not only return such document, but to do return
the document and/or a script to keep the UI in sync.

I'm currently returning the document by doing the following as part of
the callback:

downloadFile
self requestContext respond: [:response |
   response
     doNotCache;
     attachmentWithFileName: ...;
     contentType: ...,
     binary;
     nextPutAll: byteArray;
     respond
]

And I'd like to do something like.

html anchor
  jsUrl;
  onClick: (html jQuery ajax
              callback: [self downloadFile];
              script: [:s | ... ]);
  with: 'Download file'.

Regards,

--
Esteban A. Maringolo
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside