How do I make a RESTful call such as POST, GET, PUT, and DELETE from Amber? I think you can do it from JQuery, but I don't know the syntax.
-- 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. |
From the top of my head, I think I remember it was: jQuery get: 'url' success: [ :response | response whatever ] But I can't test it right now...best take a look at the jQuery API documentation :) El dia 24/05/2015 17.18, "Richard Eng" <[hidden email]> va escriure:
--
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. |
Oh, so 'jQuery' is the object? I didn't know what object to use to send messages to.
-- On Sunday, 24 May 2015 11:33:47 UTC-4, Bernat Romagosa 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. |
Richard Eng wrote: > Oh, so 'jQuery' is the object? I didn't know what object to use to No, jQuery is not the object. If it is, it's just the side-effect of global 'jQuery' which should not be defined in the first place. Proper way to get jQuery in newest Amber is either: 1. Using the Amber wrapper. That means, package which wants to use it puts 'amber-contrib-jquery/Wrappers-JQuery' in its imports; 'amber-contrib-jquery' mapping is present (up to 0.14.13 it was included in Amber itself, in master it is already out in its own repo), and use 'JQuery current' as the code to get jQuery object, ot 2. Use jQuery lib directly (but then, you don't have #asJQuery which the wrapper brings). That means, package which wants to use it puts 'jQuery' -> 'jquery' in its imports, 'jquery' mapping is present (you must have proper jquery.amd.json and jquery itself in your project tree), and using 'jQuery' as the code to get to the jQuery object. > send messages to. > > > On Sunday, 2 4 May 2015 11:33:47 UTC-4, Bernat Romagosa wrote: > > From the top of my head, I think I remember it was: > > jQuery get: 'url' success: [ :response | response whatever ] > > But I can't test it right now...best take a look at the jQuery API > documentation :) > > El dia 24/05/2015 17.18, "Richard Eng" <[hidden email] > <javascript:>> va escriure: > > How do I make a RESTful call such as POST, GET, PUT, and > DELETE from Amber? I think you can do it from JQuery, but I > don't know the syntax. > > -- > 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] > <javascript:>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > -- > You received this mes > Groups "amber-lang" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to [hidden email] > <mailto:[hidden email]>. > For more options, visit https://groups.google.com/d/optout. -- 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. |
Though the question addresses another issue the code snippet has an
example of using XMLHttpRequest to do a RESTful call http://stackoverflow.com/questions/18472447/amber-smalltalk-and-xmlhttprequest-get --HH On 5/24/15, Herby Vojčík <[hidden email]> wrote: > > > Richard Eng wrote: >> Oh, so 'jQuery' is the object? I didn't know what object to use to > > No, jQuery is not the object. If it is, it's just the side-effect of global > 'jQuery' which should not be defined in the first place. > > Proper way to get jQuery in newest Amber is either: > 1. Using the Amber wrapper. That means, package which wants to use it puts > 'amber-contrib-jquery/Wrappers-JQuery' in its imports; > 'amber-contrib-jquery' mapping is present (up to 0.14.13 it was included in > Amber itself, in master it is already out in its own repo), and use 'JQuery > current' as the code to get jQuery object, ot > 2. Use jQuery lib directly (but then, you don't have #asJQuery which the > wrapper brings). That means, package which wants to use it puts 'jQuery' -> > 'jquery' in its imports, 'jquery' mapping is present (you must have proper > jquery.amd.json and jquery itself in your project tree), and using 'jQuery' > as the code to get to the jQuery object. > >> send messages to. >> >> >> On Sunday, 2 > 4 May 2015 11:33:47 UTC-4, Bernat Romagosa wrote: >> >> From the top of my head, I think I remember it was: >> >> jQuery get: 'url' success: [ :response | response whatever ] >> >> But I can't test it right now...best take a look at the jQuery API >> documentation :) >> >> El dia 24/05/2015 17.18, "Richard Eng" <[hidden email] >> <javascript:>> va escriure: >> >> How do I make a RESTful call such as POST, GET, PUT, and >> DELETE from Amber? I think you can do it from JQuery, but I >> don't know the syntax. >> >> -- >> 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] >> <javascript:>. >> For more options, visit https://groups.google.com/d/optout >> <https://groups.google.com/d/optout>. >> >> -- >> You received this mes > sage 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] >> <mailto:[hidden email]>. >> For more options, visit https://groups.google.com/d/optout. > > -- > 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. > -- 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. |
In reply to this post by Herby Vojčík
Maybe I'm too simple minded, but I tried the following, which doesn't seem to do anything:
--
If you take the getJSON: parameter and put it in your browser, you WILL see JSON output. On Sunday, 24 May 2015 12:05:34 UTC-4, Herby 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. |
Hi Richard, I've just tried right from the web IDE, and it worked with a random JSON API: However, it didn't work with yours, and here's what the console spits out: I don't know what your setup is, but you probably need to deal with CORS and allow your domain to query your web service. Basically, you'll need to set up your "access-control-allow-origin" policy in the HTTP response header to match the domain from which you make the request. Hope it helps! Bernat. 2015-05-27 20:43 GMT+02:00 Richard Eng <[hidden email]>:
Bernat Romagosa.
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. |
It is probably a CORS issue and the stackoverflow question link I sent
earlier deals with this http://stackoverflow.com/questions/18472447/amber-smalltalk-and-xmlhttprequest-get http://en.wikipedia.org/wiki/Same-origin_policy You do not need jQuery: you can do it like the following code snippet shows. | req | req := XMLHttpRequest new. req open: 'GET' url: 'http://www.stackoverflow.com/' asynchronous: false. req send: ''. req responseText On 5/27/15, Bernat Romagosa <[hidden email]> wrote: > Hi Richard, > > I've just tried right from the web IDE, and it worked with a random JSON > API: > > [image: Imatge inserida 1] > > However, it didn't work with yours, and here's what the console spits out: > > [image: Imatge inserida 2] > > I don't know what your setup is, but you probably need to deal with CORS > and allow your domain to query your web service. Basically, you'll need to > set up your "access-control-allow-origin" policy in the HTTP response > header to match the domain from which you make the request. > > Hope it helps! > > Bernat. > > 2015-05-27 20:43 GMT+02:00 Richard Eng <[hidden email]>: > >> Maybe I'm too simple minded, but I tried the following, which doesn't >> seem >> to do anything: >> >> jQuery = JQuery current. >> >> jQuery getJSON: 'https://67.213.70.251/tut_server/default/api/all' >> >> onSuccess: [:jsonData | '#output-list' asJQuery append: 'json shit'] >> >> >> If you take the getJSON: parameter and put it in your browser, you WILL >> see JSON output. >> >> >> On Sunday, 24 May 2015 12:05:34 UTC-4, Herby wrote: >> >>> >>> >>> Richard Eng wrote: >>> > Oh, so 'jQuery' is the object? I didn't know what object to use to >>> >>> No, jQuery is not the object. If it is, it's just the side-effect of >>> global 'jQuery' which should not be defined in the first place. >>> >>> Proper way to get jQuery in newest Amber is either: >>> 1. Using the Amber wrapper. That means, package which wants to use it >>> puts 'amber-contrib-jquery/Wrappers-JQuery' in its imports; >>> 'amber-contrib-jquery' mapping is present (up to 0.14.13 it was included >>> in >>> Amber itself, in master it is already out in its own repo), and use >>> 'JQuery >>> current' as the code to get jQuery object, ot >>> 2. Use jQuery lib directly (but then, you don't have #asJQuery which >>> the wrapper brings). That means, package which wants to use it puts >>> 'jQuery' -> 'jquery' in its imports, 'jquery' mapping is present (you >>> must >>> have proper jquery.amd.json and jquery itself in your project tree), and >>> using 'jQuery' as the code to get to the jQuery object. >>> >>> > send messages to. >>> > >>> > >>> > On Sunday, 2 >>> 4 May 2015 11:33:47 UTC-4, Bernat Romagosa wrote: >>> > >>> > From the top of my head, I think I remember it was: >>> > >>> > jQuery get: 'url' success: [ :response | response whatever ] >>> > >>> > But I can't test it right now...best take a look at the jQuery API >>> > documentation :) >>> > >>> > El dia 24/05/2015 17.18, "Richard Eng" <[hidden email] >>> > <javascript:>> va escriure: >>> > >>> > How do I make a RESTful call such as POST, GET, PUT, and >>> > DELETE from Amber? I think you can do it from JQuery, but I >>> > don't know the syntax. >>> > >>> > -- >>> > 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] >>> > <javascript:>. >>> > For more options, visit https://groups.google.com/d/optout >>> > <https://groups.google.com/d/optout>. >>> > >>> > -- >>> > You received this mes >>> sage 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] >>> > <mailto:[hidden email]>. >>> > For more options, visit https://groups.google.com/d/optout. >>> >> -- >> 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. >> > > > > -- > Bernat Romagosa. > > -- > 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. > -- 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. |
H. Hirzel wrote: > It is probably a CORS issue and the stackoverflow question link I sent > earlier deals with this > > http://stackoverflow.com/questions/18472447/amber-smalltalk-and-xmlhttprequest-get > > http://en.wikipedia.org/wiki/Same-origin_policy > > You do not need jQuery: you can do it like the following code snippet shows. > > > | req | > req := XMLHttpRequest new. > req open: 'GET' url: 'http://www.stackoverflow.com/' asynchronous: false. Oh! Async: false? Try hardly to avoid. That's definitely not the right thing to get used to ... > req send: ''. > req responseText -- 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. |
Agreed. Testing code to evaluate in a workspace....
On 5/27/15, Herby Vojčík <[hidden email]> wrote: > > > H. Hirzel wrote: >> It is probably a CORS issue and the stackoverflow question link I sent >> earlier deals with this >> >> http://stackoverflow.com/questions/18472447/amber-smalltalk-and-xmlhttprequest-get >> >> http://en.wikipedia.org/wiki/Same-origin_policy >> >> You do not need jQuery: you can do it like the following code snippet >> shows. >> >> >> | req | >> req := XMLHttpRequest new. >> req open: 'GET' url: 'http://www.stackoverflow.com/' asynchronous: false. > > Oh! Async: false? Try hardly to avoid. That's definitely not the right > thing to get used to ... > >> req send: ''. >> req responseText > > -- > 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. > -- 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. |
In reply to this post by Hannes Hirzel
I'm puzzled by the code snippet. I don't see how the "answer" for CORS works. The meta statement seems totally irrelevant.
-- I'm looking for a nice, simple way to get around CORS. It is not the focus of my Amber project and I don't want to be distracted by it. I just need a way for my Amber app to talk to a REST server. On Wednesday, 27 May 2015 15:31:52 UTC-4, Hannes wrote: It is probably a CORS issue and the stackoverflow question link I sent 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. |
There used to be corsproxy.com, but it doesn't exist anymore. You could setup one of your own (npm install corsproxy) but really, it's much easier to just take care of the CORS policy in the server you already have. This is not an Amber issue, any client web call would fail in the same way... El dia 28/05/2015 6.04, "Richard Eng" <[hidden email]> va escriure:
--
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. |
There are also CORS browser extensions that do the trick. Some browsers have a developer option as well that deactivates CORS when site is browsed from localhost.
Norbert
--
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. |
HOORAY! I got it to work!
-- I followed this suggestion: http://enable-cors.org/server_apache.html Now, my jQuery snippet works: jQuery = JQuery current. jQuery getJSON: 'https://miramar21.com/tut_server/default/api/all' onSuccess: [:jsonData | '#output-list' asJQuery append: 'json shit']. I prefer this because the syntax is so much cleaner. And since jQuery is built into Amber, why not use it? Now, my next task is to parse the JSON object (jsonData). Does Amber have a facility for doing this? (A Google search shows an ugly mish-mash.) On Thursday, 28 May 2015 03:16:18 UTC-4, Norbert Hartl 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. |
Richard,
jQuery is NOT built in Amber. Dňa 28. mája 2015 17:24:11 CEST používateľ Richard Eng <[hidden email]> napísal:
--
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. |
Dear Richard, Amber 014.14 has been release a couple of days ago. JQuery has been completely removed from Amber core libraries. Take a look at the migration guide if you actually require JQuery in your project: For further details on how to use XHR starting from Amber 0.14.14 see Herby's post: Best, Manfred On Thu, May 28, 2015 at 5:44 PM, Herby Vojčík <[hidden email]> 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. |
In reply to this post by Herby Vojčík
Hmmm, I wonder how I got jQuery on my Mac.
-- Okay, I guess I should use XMLHttpRequest instead. (I presume that's just straight JavaScript.) On Thursday, 28 May 2015 11:44:44 UTC-4, Herby 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. |
Dear Richard, there is no wondering required. Just read the migration notice carefully. Since you are probably using the Amber IDE, jQuery was pulled in along with the IDE. The IDE uses the Web package which in turn uses JQuery. Or you are using a version of amber-cli which was published before 014.14 was out. Best, Manfred On Thu, May 28, 2015 at 7:47 PM, Richard Eng <[hidden email]> 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. |
In reply to this post by horrido
Richard Eng wrote: > Hmmm, I wonder how I got jQuery on my Mac. > > Okay, I guess I should use XMLHttpRequest instead. (I presume that's > just straight JavaScript.) No need to, if you want to use jQuery. Just make it explicit that your package wants to use it (import the jQuery wrapper and use 'JQuery current', as already written below). If you want to use XHR, you can (and it's probably useful to, to make your code more platform agnostiv) use 'Platform newXhr' to make an instance of it. Herby -- 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 |