[Seaside] Non-blocking jQuery load

jtuchel at objektfabrik.de jtuchel at objektfabrik.de
Sat Nov 21 13:56:27 UTC 2015


Hi Johan,

I was referring to the timeout: parameter of $.ajax() which is not 
supported by .load() (see here: 
http://stackoverflow.com/questions/16129292/how-do-i-set-a-timeout-in-load-jquery-for-this-particular-example).

But the wrapping of the load()-call within a setTimout() works 
perfectly. So your suggestion of  "addDecoration: (JSTimeout duration: 
aDuration)" works perfectly!


So you taught me at least 3 important lessons today:

1. I can addLoadScript: in an ajax callback
2. addDecoration: in JSObjects to wrap stuff into a function
3. The handling of Ajax Callbacks on the Seaside Server blocks "normal" 
callbacks (I know of no better way to name it)


We now have a dashboard that reacts to clicks immediately.
There is one thing with a bitter taste for now: the server side Ajax 
processing is not stopped, so the background process still burns cycles 
although nobody is interested in its results any more. It should be easy 
to do this, because it is just a question of terminating background 
processes and keep track of what background processes are currently 
running for this session. Combined with another Ajax call and a bit of 
bookeeping we'll be able to save cycles should the need arise. For now 
we just enjoy the improvements ;-)

Thanks for great help!

Joachim



Am 21.11.15 um 09:14 schrieb Johan Brichau:
> Hi Joachim,
>
> I’m not really sure what “timeout” you are referring to, but your 
> reply makes me think of an issue (see below).
> The timeout method I used in my code snippet corresponds to 
> JavaScript’s setTimeout function wrapped around the ajax request. So, 
> in that sense, any JS expression supports that.
>
> BUT, an issue regarding the #timeout: message pops to my mind:
>
> There are two unrelated implementations of the #timeout: message. The 
> one on (JSObject>>timeout:) is to wrap a JS statement in a setTimeout 
> function, the other one on (JQAjaxSetup>>timeout:) is to set a timeout 
> value for the ajax request. Unfortunately, the latter overrides the 
> former. I suspect that the code I sent you hits that issue. You can 
> solve it by sending "addDecoration: (JSTimeout duration: aDuration)” 
> instead of #timeout:.
>
> I got bitten by this before. I ignored it (working around it by using 
> #addDecoration:). A colleague of mine got bitten just a couple of 
> weeks ago. I think you got bitten too now.
> I think I should no longer ignore this unpolymorphic override anymore 
> :/ [1]
>
> [1] https://github.com/SeasideSt/Seaside/issues/861
>
>> On 20 Nov 2015, at 10:07, jtuchel <jtuchel at objektfabrik.de 
>> <mailto:jtuchel at objektfabrik.de>> wrote:
>>
>> Johan,
>>
>> thanks a lot for this idea and code draft. It is of course exactly 
>> what I need.
>>
>> Given that we use that background process thing at another place 
>> (show a progress dialog for a long running process), it is sad but 
>> trrue I didn't think of the same technique for this purpose. But of 
>> course this is the perfect thing to do. Thus the Ajax's will be short 
>> running and the browser won't wait for the data. Definitely worth it.
>>
>> Once again: thanks a lot for your guidance and help! I still hope one 
>> day I can give something back.
>>
>> Maybe a drink in Prague at ESUG 2016 counts as a first attempt? ;-)
>>
>> Joachim
>>
>>
>>
>> Am 20.11.15 um 09:52 schrieb Johan Brichau-2 [via Smalltalk]:
>>>
>>>> On 20 Nov 2015, at 09:57, Johan Brichau <[hidden email] 
>>>> <x-msg://11/user/SendEmail.jtp?type=node&node=4862164&i=0>> wrote:
>>>>
>>>> This perfectly fits your decoration implementation. Something along 
>>>> these lines (disclaimer: untested code written in email client :) :
>>>
>>> The code I sent before will poll a bit too quickly :) I forgot to 
>>> add a wait on the client:
>>>
>>>
>>> replaced
>>> ifTrue: [div with: [self renderNextOn: html]]
>>> ifFalse: [
>>> html document addLoadScript: (self loadScriptOn: html).
>>> div with: [
>>> html image src: someSpinnerImage
>>> html space; text: self message]]
>>>
>>> loadScriptOn: html
>>>
>>> (html jQuery: self idSelector) load html: [:r |
>>> self isDataReady
>>> ifTrue:[ replaced := true.
>>>   self renderNextOn: html]
>>> ifFalse: [ r addLoadScript: ((self loadScriptOn: r) timeout: 1000) ]).
>>>
>>>
>>> _______________________________________________
>>> seaside mailing list
>>> [hidden email] 
>>> <x-msg://11/user/SendEmail.jtp?type=node&node=4862164&i=1>
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>>
>>> ------------------------------------------------------------------------
>>> If you reply to this email, your message will be added to the 
>>> discussion below:
>>> http://forum.world.st/Non-blocking-jQuery-load-tp4861881p4862164.html
>>> To unsubscribe from Non-blocking jQuery load,click here.
>>> NAML 
>>> <http://forum.world.st/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>>
>> -- 
>> -----------------------------------------------------------------------
>> Objektfabrik Joachim Tuchel[hidden email] <x-msg://11/user/SendEmail.jtp?type=node&node=4862167&i=0>
>> Fliederweg 1http://www.objektfabrik.de
>> D-71640 Ludwigsburghttp://joachimtuchel.wordpress.com
>> Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1
>>
>>
>> ------------------------------------------------------------------------
>> View this message in context:Re: Non-blocking jQuery load 
>> <http://forum.world.st/Non-blocking-jQuery-load-tp4861881p4862167.html>
>> Sent from theSeaside General mailing list archive 
>> <http://forum.world.st/Seaside-General-f86180.html>atNabble.com 
>> <http://nabble.com/>.
>> _______________________________________________
>> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20151121/4db7b82e/attachment-0001.htm


More information about the seaside mailing list