Re: [AJAX] #script: & #html: vs #onSuccess: & #load & #html:
"Cyril Ferlicot D." <[email protected]>
| Newsgroups | gmane.comp.lang.smalltalk.squeak.seaside |
|---|---|
| Message-ID | <[email protected]> |
Le 24/09/2016 à 08:48, Johan Brichau a écrit : > Hi Mariano, > > First button does a single ajax call and responds a js script. > Second button does two ajax calls, first one without a response content, second one with a html response content. > > Both achieve the same end result but the second one requires two request-response cycles to your server. > The second one will thus achieve the end result slower than the first one. > > We typically also try to optimize as much as possible into single ajax requests. > > Mind that you _can_ combine a single primary and multiple secondary callback blocks into a single ajax call. > A primary callback is a callback that responds a content to the client (#script:, #html:, #json:, #text, ….) > A secondary callback is a callback that does not respond content (#callback:value:, #callback:passengers:, #callback:json: , …) > There is an exception to this rule, #callback: is implemented in the Seaside jQuery binding as a primary callback, even if it does not return any content. > > Although for this example, I would actually write it as follows, because the #callback: block is a primary callback. > > html button > bePush; > onClick: (html jQuery id: ‘myDivId’ load html: [:r | | … do some other stuff …. then ... self renderMyDivOn: r. ] ) > value: ‘Test’ > Hi! With this example how is manage the case where the session expire? In general I do: onClick: (html jQuery ajax callback: [ ]; onSuccess: ( (html jQuery id: 'myDivId') load html: [ :r | self renderMyDivOn: r. ]); onError: 'location.reload();' "probably session expiration"); > Now, it also depends of the ‘myDivId’ is known when rendering the button or not, but in this simple example this would yield the same result ;) > > cheers > Johan > > > _______________________________________________ > seaside mailing list > [email protected] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > -- Cyril Ferlicot http://www.synectique.eu 2 rue Jacques Prévert 01, 59650 Villeneuve d'ascq France _______________________________________________ seaside mailing list [email protected] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
signature.asc
(application/pgp-signature, 819 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJX5mBmAAoJEBzpUtxBqUIDB5oQAILoa8agcwECpKv57kQ/CFCq OD8+BJtzzegk6VSCPiB6DM9MiQnyINHA5QtrKsk/0/mSrLGbLdQfPEmibzMYmAah zUtWD+gNoYBMgr9u6R83yCY0jwmcQMoiK06cUg9t6blCDNm4+HTSiLJSVF983t2r HpvQHHF/FGpnPpdY2F11ZtCqza2qzOe1RmNUjY4+z5gZQ9RSa8td7anRyI5Lp3Kx RUgcxCOBD1BOgnNT02DXNwr3dX/CPKE1j7u3dUEwOUDS07nzrp7/Y6G/wPyb93pq pSY0k3DUG48YW9sL2UqhInGl2vUyR6AIm7VjgiTt0ZPLNrWMGYhLUuFtAlcc9H5k mdKqSr9B6cOCPvkhLXsBsUYh8gH/Rgd8MmxzEJD7zR50fz0V0BYSWjZYBp47FPHy /zK/ccydRpWmF/WIUXBFxLhkXH/Vu52dIT1IVahlS8BQNNr1wXaR2hHOUqlkMuuz k+FCXV6vZWzypTDoHCOHGDn3e6FBOKrmIsquwz8U6IDLElzU5GXUJk8pEq8CzRuW DSDE9ArmiHlL07SVxYVn/1dZqlLS+TtkNGsq4gRc+UT0Z8gGUJ4Lk3HChMFXW6A5 nlBeu/RKpce8LthWUkz1nEU7o3cUcX6SWVLavkTAZkTdSUYxqXqbYsfSJPBArymx uySzrQPT6KTyTPxQw15r =DWZJ -----END PGP SIGNATURE-----