Administrator
|
I'm assuming this problem is related to the one I described [1] last time I did a "serious" Amber project.
`(jQuery getJSON: './suppliers.json') responseJSON` -> DNU but: `(jQuery getJSON: './suppliers.json') inspect` and then `self responseJSON` from that inspector works! I still can't wrap my head around the difference :/ [1] http://forum.world.st/Create-JS-Object-in-Smalltalk-tt4769429.html
Cheers,
Sean |
Sean P. DeNigris wrote: > I'm assuming this problem is related to the one I described [1] last time I > did a "serious" Amber project. > > `(jQuery getJSON: './suppliers.json') responseJSON` -> DNU > but: > `(jQuery getJSON: './suppliers.json') inspect` and then `self > responseJSON` from that inspector works! > > I still can't wrap my head around the difference :/ Asynchrony? ;-) You're using jQuery API the wrong way, you should not treat it as synchronous, but fully embrace the async way. (jQuery ajax: #{'dataType'->'json'. 'url'->'./suppliers.json')) done: [ :jsonResponse | ... ]; fail: [ "error" ] And last, but not least: don't use 'jQuery'. You get hurt when your code fails in production. From version 0.14.14, jQuery is not part of Amber, you should imports 'Wrappers-JQuery' and use 'JQuery current' (more in wiki migration guide). -- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Administrator
|
I was hoping you wouldn't say that ha ha! What if you really do want to wait for the value? In this case, I am interfacing with code imported from Pharo (which I would like to remain compatible). It expects a value to be returned...
Cheers,
Sean |
Sean P. DeNigris wrote: > Herby Vojčík wrote >> Asynchrony? ;-) > > I was hoping you wouldn't say that ha ha! > > What if you really do want to wait for the value? In this case, I am > interfacing with code imported from Pharo (which I would like to remain > compatible). It expects a value to be returned... Never used that, everyone discourages it, but there _is_ an option to make that call synchronous. Look in jQuery docs. -- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Herby Vojčík wrote: > > > Sean P. DeNigris wrote: >> Herby Vojčík wrote >>> Asynchrony? ;-) >> >> I was hoping you wouldn't say that ha ha! >> >> What if you really do want to wait for the value? In this case, I am >> interfacing with code imported from Pharo (which I would like to remain >> compatible). It expects a value to be returned... > > Never used that, everyone discourages it, but there _is_ an option to > make that call synchronous. Look in jQuery docs. But even if you escape this time, you cannot escape entirely, as Pharo has green threads, but Amber doesn't, as JS doesn't and is built around callbacks (or promises if you like that more). Code that deliberately waits in one thread, letting others go on, simply cannot be ported as-is and must be rewritten. -- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Administrator
|
Noted, but in this case, it feels like the right thing to do. I ended up with: response := JQuery current ajax: #{ #dataType -> 'json'. #url -> './egg_suppliers.json'. #async -> false }. which I adapted from http://stackoverflow.com/questions/13009755/getjson-synchronous
Cheers,
Sean |
Sean,
-- I don't remember the details any more, but I spent quite some time trying to use async: false in $.ajax() in our Seaside app (which doesn't really matter) and decided to give up on it after wasting hours, maybe days hunting some problem. Shame on me, but I can't tell for sure any more what the problem was. Maybe it was IE or other shit of that kind. So I advice you to take the strong discouragement about synchronous ajax seriously. It will pay back either way ;-) Joachim Am Montag, 15. Juni 2015 22:01:02 UTC+2 schrieb Sean DeNigris: Herby Vojčík wrote You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble | Edit this page |