Piotr Kukielka
Piotr Kukielka

Reputation: 3872

How to make cross-site POST request with easyXDM?

What I'm trying to do is to implement some simple cross-site client calls to RESTful service.
Right now I'm trying to use easyXDM for this purpose. It seems to be working, but when I'm using it according to example (https://github.com/oyvindkinsey/easyXDM#readme) on server side I'm always getting something like:

GET /?xdm_e=http%3A%2F%2Flocalhost%3A8081&xdm_c=default4817&xdm_p=1 HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Referer: http://localhost:8081/requester.html
User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) 
Ubuntu/11.04 Chromium/12.0.742.112 Chrome/12.0.742.112 Safari/534.30
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4
Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.3

even if it's explicitly said in the code:

method: "POST"

Is there any way to get real POST request with easyXDM?
And if not, then at what tool I should look instead?

Upvotes: 3

Views: 4063

Answers (1)

JasonStoltz
JasonStoltz

Reputation: 3110

Let me first say that easyXDM is totally capable of doing this, I'm using it to do exactly what you're describing.

The example you'll probably want to follow is this: http://easyxdm.net/wp/2010/03/17/cross-domain-ajax/

It appears to me, that when you are configuring your "RPC" object, you are passing your end-point url to the "remote" parameter. That's not what easyXDM expects in that parameter, which is why you experience this strange behavior.

Instead, what you should do is install the "index.html" file (provided with the easyXDM download) on your server, and pass the url to that index.html file to the "remote" parameter. You then pass your endpoint url when calling "request" on the RPC object.

If you follow the instructions on that link I promise you it will work.

Upvotes: 2

Related Questions