Likely the problem, see: http://meteatamel.wordpress.com/2011/02/11/access-control-allow-origin/ and from there on: https://developer.mozilla.org/En/HTTP_Access_Control
On Fri, Sep 23, 2011 at 11:40 PM, Richard Durr <[email protected]>wrote: > Maybe the Access-Control-Allow-Origin blocks because of the different > ports? > > On Fri, Sep 23, 2011 at 5:56 PM, Bernat Romagosa < > [email protected]> wrote: > >> 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<http://localhost/>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. >> > >
