No idea, but your intent is really valuable

Alexandre



Le 23 sept. 2011 à 11:56, Bernat Romagosa <[email protected]> a 
écrit :

> Ok, so I've just learnt I should be doing:
> 
> answerTo: aRequest 
>       | response |
>       aRequest postDataKeys do: [:eachKey | Transcript show: (aRequest 
> postDataAt: eachKey) value].
>       response := HTTPResponse ok.
>       ^response
> 
> But then the client's javascript console shows: "XMLHttpRequest cannot load 
> http://localhost:4001/amber/. Origin http://localhost:4000 is not allowed by 
> Access-Control-Allow-Origin."
> 
> Ideas?
> 
> 2011/9/23 Bernat Romagosa <[email protected]>
> Hi lists,
> 
> I'm trying to get Amber and Pharo to talk to each other by using Ajax. So 
> far, using an Ajax wrapper that Laurent wrote, I managed to get Pharo to 
> receive a message from Amber by doing:
> 
>       |ajax|
>       ajax := (Ajax url: 'http://localhost:4001/amber/').
>       ajax options
>               at: 'type' put: 'POST';
>               at: 'data' put: 'Hi Pharo!';
>               at: 'timeout' put: 500.
>       ajax onSuccessDo: [console log: 'ok!'];
>               onErrorDo: [console log: 'not so ok...'].
>       ajax send
> 
> This is captured by a Swazoo resource, that does the following:
> 
> answerTo: aRequest 
>       | response |
>       [aRequest postData stream anyDataReady] 
>               whileTrue:
>                       [Transcript show: aRequest postData stream next].
> 
>       response := HTTPResponse ok.
>       response
>               contentType: 'text/plain';
>               entity: 'Done!'.
>       ^response
> 
> My intention here is just to read the message data and return an OK response, 
> but for some reason stream anyDataReady keeps evaluating to true even when 
> there's no more data to read, so the code underneath is never executed. The 
> Transcript shows 'Hi Pharo!' though, so I'm sure the request is being 
> received and read.
> 
> Any light shed on this would be of great help...
> 
> Thanks!
> 
> -- 
> Bernat Romagosa.
> 
> 
> 
> -- 
> Bernat Romagosa.

Reply via email to