Hi guys,
Maybe the subject of the email is not the most accurate. What I need is the following. From seaside, I am calling a JS library using "html script: 'xxx' ". Now, that JS libs provides me a feature in which it can do an AJAX request to the "url/someAPI" and send some JSON (what I need).
When I do an ajax request from within seaside I can easily attach a callback. However, in this case, I don't know how to do that. What I need is a callback associated to url/someAPI and I need to read the JSON sent in that ajax request.
Any idea how can I do this? _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
you’re not saying if url/someAPI is your server or not and, if yours, if it’s a seaside app or not
On Jul 9, 2014, at 10:57 AM, Mariano Martinez Peck <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
On Wed, Jul 9, 2014 at 11:06 AM, Sebastian Sastre <[hidden email]> wrote:
It can be any server, in my case, yes, I would like to use the same server/app from where I am using the plugin.
yes it is. And it must run in gemstone and pharo. Note that the url can, of course, be specified. It is an ajax request.
Thanks,
Mariano http://marianopeck.wordpress.com _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
can you use jquery success callback? like $.ajax(blabla ’success’: ‘a/callback/url/withASeasideActionToYourBackend' ) On Jul 9, 2014, at 12:15 PM, Mariano Martinez Peck <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Mariano Martinez Peck
Hi Mariano,
I assume that the JS library takes an option parameter to specify the url of an ajax callback? There are (at least) three different way to solve this: 1. use the url of an ajax callback created during Seaside rendering. This is how to do that: urlForXHRAction: aBlock "Answer an action URL that will evaluate aBlock when it is requested." ^ renderContext actionUrl withField: (renderContext callbacks store: (JSAjaxCallback on: aBlock)) urlForJsonCallback: aCallback ^ (self urlForXHRAction: [ self requestContext respond: [:response | response doNotCache; contentType: WAMimeType applicationJson; nextPutAll: (WAJsonCanvas builder render: aCallback)]]) I copied the above from an image where I use Seaside 3.1.x. If you use 3.0.x, you need a different json callback. Let me know if you need that. You can use it in your rendering method as follows: url := self urlForJsonCallback: [:json | json array:[ ... ] ] 2. use a RestfulComponentFilter from Seaside-REST. You can define a filter that captures (REST) urls send back to your application's session. If you define a filter, you would pass the url that is captured by the filter to the JS library. More info can be found in the Seaside book: http://book.seaside.st/book/advanced/restful/handler-filter - use a separate (REST) api In that case, you would pass a full url to another service (possibly served by the same Smalltalk image) to the JS lib. Hope this helps! Johan On 09 Jul 2014, at 15:57, Mariano Martinez Peck <[hidden email]> wrote: > Hi guys, > > Maybe the subject of the email is not the most accurate. What I need is the following. From seaside, I am calling a JS library using "html script: 'xxx' ". Now, that JS libs provides me a feature in which it can do an AJAX request to the "url/someAPI" and send some JSON (what I need). > > When I do an ajax request from within seaside I can easily attach a callback. However, in this case, I don't know how to do that. What I need is a callback associated to url/someAPI and I need to read the JSON sent in that ajax request. > > Any idea how can I do this? > > Thanks in advance, > > -- > Mariano > http://marianopeck.wordpress.com > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |