Making RESTful Calls

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

Making RESTful Calls

horrido
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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

Bernat Romagosa

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:
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.

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

horrido
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:

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" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="CXu9GNLzcNIJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">horrido...@...> 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CXu9GNLzcNIJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">amber-lang+...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

Herby Vojčík


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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

Hannes Hirzel
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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

horrido
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:

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 amber-lang+...@googlegroups.com
>         <javascript:>.
>         For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout
>         <<a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="KB1IhAtZG7MJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">amber-lang+...@googlegroups.com
> <mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="KB1IhAtZG7MJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">amber-lang+unsubscribe@...>.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

Bernat Romagosa
Hi Richard,

I've just tried right from the web IDE, and it worked with a random JSON API:

Imatge inserida 1

However, it didn't work with yours, and here's what the console spits out:

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. 
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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

Hannes Hirzel
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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

Herby Vojčík


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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

Hannes Hirzel
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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

horrido
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
earlier deals with this

<a href="http://stackoverflow.com/questions/18472447/amber-smalltalk-and-xmlhttprequest-get" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F18472447%2Famber-smalltalk-and-xmlhttprequest-get\46sa\75D\46sntz\0751\46usg\75AFQjCNEc30LcLaapejPXq23gdkWtk8vd2w';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F18472447%2Famber-smalltalk-and-xmlhttprequest-get\46sa\75D\46sntz\0751\46usg\75AFQjCNEc30LcLaapejPXq23gdkWtk8vd2w';return true;">http://stackoverflow.com/questions/18472447/amber-smalltalk-and-xmlhttprequest-get

<a href="http://en.wikipedia.org/wiki/Same-origin_policy" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FSame-origin_policy\46sa\75D\46sntz\0751\46usg\75AFQjCNGFD8uvaWJaXz_9_HHuyTnrZ-_fEg';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FSame-origin_policy\46sa\75D\46sntz\0751\46usg\75AFQjCNGFD8uvaWJaXz_9_HHuyTnrZ-_fEg';return true;">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: '<a href="http://www.stackoverflow.com/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.stackoverflow.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNFM_WMrFTxIfr8A2lUvcVGvDLWeEg';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.stackoverflow.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNFM_WMrFTxIfr8A2lUvcVGvDLWeEg';return true;">http://www.stackoverflow.com/' asynchronous: false.
req send: ''.
req responseText




On 5/27/15, Bernat Romagosa <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="SsYvKYq96QUJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">tibabenfor...@gmail.com> 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 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="SsYvKYq96QUJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">horrido...@...>:
>
>> Maybe I'm too simple minded, but I tried the following, which doesn't
>> seem
>> to do anything:
>>
>> jQuery = JQuery current.
>>
>> jQuery getJSON: '<a href="https://67.213.70.251/tut_server/default/api/all" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2F67.213.70.251%2Ftut_server%2Fdefault%2Fapi%2Fall\46sa\75D\46sntz\0751\46usg\75AFQjCNEKr-p_kJCL6UAeDSlhejdE8IpizQ';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2F67.213.70.251%2Ftut_server%2Fdefault%2Fapi%2Fall\46sa\75D\46sntz\0751\46usg\75AFQjCNEKr-p_kJCL6UAeDSlhejdE8IpizQ';return true;">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 amber-lang+...@googlegroups.com
>>> >         <javascript:>.
>>> >         For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout
>>> >         <<a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 amber-lang+...@googlegroups.com
>>> > <mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="SsYvKYq96QUJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">amber-lang+unsubscribe@...>.
>>> > For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="SsYvKYq96QUJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">amber-lang+...@googlegroups.com.
>> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="SsYvKYq96QUJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">amber-lang+...@googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

Bernat Romagosa

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:
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
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.

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

NorbertHartl
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


Am 28.05.2015 um 08:52 schrieb Bernat Romagosa <[hidden email]>:

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:
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
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.

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

horrido
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:
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


Am 28.05.2015 um 08:52 schrieb Bernat Romagosa <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="VDhJYl_2L_sJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">tibabenfor...@gmail.com>:

There used to be <a href="http://corsproxy.com/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fcorsproxy.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHGgb34guXlURqofP3Rdn0GvISDBw';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fcorsproxy.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHGgb34guXlURqofP3Rdn0GvISDBw';return true;">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" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="VDhJYl_2L_sJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">horrido...@...> va escriure:
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
earlier deals with this

<a href="http://stackoverflow.com/questions/18472447/amber-smalltalk-and-xmlhttprequest-get" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F18472447%2Famber-smalltalk-and-xmlhttprequest-get\46sa\75D\46sntz\0751\46usg\75AFQjCNEc30LcLaapejPXq23gdkWtk8vd2w';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F18472447%2Famber-smalltalk-and-xmlhttprequest-get\46sa\75D\46sntz\0751\46usg\75AFQjCNEc30LcLaapejPXq23gdkWtk8vd2w';return true;">http://stackoverflow.com/questions/18472447/amber-smalltalk-and-xmlhttprequest-get

<a href="http://en.wikipedia.org/wiki/Same-origin_policy" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FSame-origin_policy\46sa\75D\46sntz\0751\46usg\75AFQjCNGFD8uvaWJaXz_9_HHuyTnrZ-_fEg';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FSame-origin_policy\46sa\75D\46sntz\0751\46usg\75AFQjCNGFD8uvaWJaXz_9_HHuyTnrZ-_fEg';return true;">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: '<a href="http://www.stackoverflow.com/" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.stackoverflow.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNFM_WMrFTxIfr8A2lUvcVGvDLWeEg';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.stackoverflow.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNFM_WMrFTxIfr8A2lUvcVGvDLWeEg';return true;">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: '<a href="https://67.213.70.251/tut_server/default/api/all" rel="nofollow" target="_blank" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2F67.213.70.251%2Ftut_server%2Fdefault%2Fapi%2Fall\46sa\75D\46sntz\0751\46usg\75AFQjCNEKr-p_kJCL6UAeDSlhejdE8IpizQ';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2F67.213.70.251%2Ftut_server%2Fdefault%2Fapi%2Fall\46sa\75D\46sntz\0751\46usg\75AFQjCNEKr-p_kJCL6UAeDSlhejdE8IpizQ';return true;">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 amber-lang+...@googlegroups.com
>>> >         <javascript:>.
>>> >         For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout
>>> >         <<a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 amber-lang+...@googlegroups.com
>>> > <mailto:amber-lang+[hidden email]>.
>>> > For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 amber-lang+...@googlegroups.com.
>> For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 amber-lang+...@googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="VDhJYl_2L_sJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">amber-lang+...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="VDhJYl_2L_sJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">amber-lang+...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

Herby Vojčík
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:
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:
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


Am 28.05.2015 um 08:52 schrieb Bernat Romagosa <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="VDhJYl_2L_sJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">tibabenfor...@gmail.com>:

There used to be <a href="http://corsproxy.com/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fcorsproxy.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHGgb34guXlURqofP3Rdn0GvISDBw';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fcorsproxy.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHGgb34guXlURqofP3Rdn0GvISDBw';return true;">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" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="VDhJYl_2L_sJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">horrido...@...> va escriure:
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
earlier deals with this

<a href="http://stackoverflow.com/questions/18472447/amber-smalltalk-and-xmlhttprequest-get" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F18472447%2Famber-smalltalk-and-xmlhttprequest-get\46sa\75D\46sntz\0751\46usg\75AFQjCNEc30LcLaapejPXq23gdkWtk8vd2w';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F18472447%2Famber-smalltalk-and-xmlhttprequest-get\46sa\75D\46sntz\0751\46usg\75AFQjCNEc30LcLaapejPXq23gdkWtk8vd2w';return true;">http://stackoverflow.com/questions/18472447/amber-smalltalk-and-xmlhttprequest-get

<a href="http://en.wikipedia.org/wiki/Same-origin_policy" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FSame-origin_policy\46sa\75D\46sntz\0751\46usg\75AFQjCNGFD8uvaWJaXz_9_HHuyTnrZ-_fEg';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FSame-origin_policy\46sa\75D\46sntz\0751\46usg\75AFQjCNGFD8uvaWJaXz_9_HHuyTnrZ-_fEg';return true;">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: '<a href="http://www.stackoverflow.com/" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.stackoverflow.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNFM_WMrFTxIfr8A2lUvcVGvDLWeEg';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.stackoverflow.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNFM_WMrFTxIfr8A2lUvcVGvDLWeEg';return true;">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: '<a href="https://67.213.70.251/tut_server/default/api/all" rel="nofollow" target="_blank" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2F67.213.70.251%2Ftut_server%2Fdefault%2Fapi%2Fall\46sa\75D\46sntz\0751\46usg\75AFQjCNEKr-p_kJCL6UAeDSlhejdE8IpizQ';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2F67.213.70.251%2Ftut_server%2Fdefault%2Fapi%2Fall\46sa\75D\46sntz\0751\46usg\75AFQjCNEKr-p_kJCL6UAeDSlhejdE8IpizQ';return true;">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 amber-lang+...@googlegroups.com
>>> >         <javascript:>.
>>> >         For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout
>>> >         <<a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 amber-lang+...@googlegroups.com
>>> > <mailto:amber-lang+[hidden email]>.
>>> > For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 amber-lang+...@googlegroups.com.
>> For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 amber-lang+...@googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="VDhJYl_2L_sJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">amber-lang+...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="VDhJYl_2L_sJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">amber-lang+...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

Manfred Kröhnert
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:
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:
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.
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:
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


Am 28.05.2015 um 08:52 schrieb Bernat Romagosa <[hidden email]>:

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:
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
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.

--
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.

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

horrido
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:
Richard,

jQuery is NOT built in Amber.

Dňa 28. mája 2015 17:24:11 CEST používateľ Richard Eng <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="TkJJgPp4IPoJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">horrido...@...> napísal:
HOORAY! I got it to work!

I followed this suggestion:  <a href="http://enable-cors.org/server_apache.html" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fenable-cors.org%2Fserver_apache.html\46sa\75D\46sntz\0751\46usg\75AFQjCNFuD0pCsD1Xf6c1CuW7oVB9YfJakg';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fenable-cors.org%2Fserver_apache.html\46sa\75D\46sntz\0751\46usg\75AFQjCNFuD0pCsD1Xf6c1CuW7oVB9YfJakg';return true;">http://enable-cors.org/server_apache.html

Now, my jQuery snippet works:

jQuery = JQuery current.
jQuery getJSON: '<a href="https://miramar21.com/tut_server/default/api/all" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fmiramar21.com%2Ftut_server%2Fdefault%2Fapi%2Fall\46sa\75D\46sntz\0751\46usg\75AFQjCNHAZ01R95pDBcaBtIXU2UXEWSl-sg';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fmiramar21.com%2Ftut_server%2Fdefault%2Fapi%2Fall\46sa\75D\46sntz\0751\46usg\75AFQjCNHAZ01R95pDBcaBtIXU2UXEWSl-sg';return true;">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:
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


Am 28.05.2015 um 08:52 schrieb Bernat Romagosa <[hidden email]>:

There used to be <a href="http://corsproxy.com/" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fcorsproxy.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHGgb34guXlURqofP3Rdn0GvISDBw';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fcorsproxy.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHGgb34guXlURqofP3Rdn0GvISDBw';return true;">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:
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
earlier deals with this

<a href="http://stackoverflow.com/questions/18472447/amber-smalltalk-and-xmlhttprequest-get" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F18472447%2Famber-smalltalk-and-xmlhttprequest-get\46sa\75D\46sntz\0751\46usg\75AFQjCNEc30LcLaapejPXq23gdkWtk8vd2w';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F18472447%2Famber-smalltalk-and-xmlhttprequest-get\46sa\75D\46sntz\0751\46usg\75AFQjCNEc30LcLaapejPXq23gdkWtk8vd2w';return true;">http://stackoverflow.com/questions/18472447/amber-smalltalk-and-xmlhttprequest-get

<a href="http://en.wikipedia.org/wiki/Same-origin_policy" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FSame-origin_policy\46sa\75D\46sntz\0751\46usg\75AFQjCNGFD8uvaWJaXz_9_HHuyTnrZ-_fEg';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FSame-origin_policy\46sa\75D\46sntz\0751\46usg\75AFQjCNGFD8uvaWJaXz_9_HHuyTnrZ-_fEg';return true;">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: '<a href="http://www.stackoverflow.com/" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.stackoverflow.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNFM_WMrFTxIfr8A2lUvcVGvDLWeEg';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.stackoverflow.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNFM_WMrFTxIfr8A2lUvcVGvDLWeEg';return true;">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: '<a href="https://67.213.70.251/tut_server/default/api/all" rel="nofollow" target="_blank" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2F67.213.70.251%2Ftut_server%2Fdefault%2Fapi%2Fall\46sa\75D\46sntz\0751\46usg\75AFQjCNEKr-p_kJCL6UAeDSlhejdE8IpizQ';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2F67.213.70.251%2Ftut_server%2Fdefault%2Fapi%2Fall\46sa\75D\46sntz\0751\46usg\75AFQjCNEKr-p_kJCL6UAeDSlhejdE8IpizQ';return true;">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 amber-lang+...@googlegroups.com
>>> >         <javascript:>.
>>> >         For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout
>>> >         <<a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 amber-lang+...@googlegroups.com
>>> > <mailto:amber-lang+[hidden email]>.
>>> > For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 amber-lang+...@googlegroups.com.
>> For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 amber-lang+...@googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 amber-lang+...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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 amber-lang+...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

Manfred Kröhnert
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:
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:
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:
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.
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:
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


Am 28.05.2015 um 08:52 schrieb Bernat Romagosa <[hidden email]>:

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:
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
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.

--
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.

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: Making RESTful Calls

Herby Vojčík
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.