5

I've to make a POST call(with parameter) to an asp form which is located on another server.

For development, I did this on the same server, and it works perfectly, but now I'm testing it on another server, and instead of receiving a 200 status, I receive a 0 status.

I think it's because it's a cross-domain AJAX call, it's the only thing which changed. So how can I make this call? Is there any file I can put on the server/client to allow this call(like flash, ...)?

Thank you!

1
  • for futher help we might need to know the natre of the ajax call Commented Jul 25, 2011 at 12:41

2 Answers 2

7

Yes, assuming you can change the server you connect to

You can implement Cross Origin Resource Sharing (CORS)

You need the server to return Access-Control-Allow-Origin: * if you want to allow all domains to access, otherwise return Access-Control-Allow-Origin: http://yourdomain.com

If you cannot change the server you are accessing, you need to use a proxy on the server your script comes from - alternatively investigate if they have published an API to return for example JSONP

More details here

and several links to the right of this questions

Sign up to request clarification or add additional context in comments.

4 Comments

the support seems quite limited at the moment.
I took a look at your link, but I can't found where I should declare all these "Access-Control-Allow-Origin", ...
@dvhh - it is supported by most modern browsers i.e. FF3.5+, Safari5, IE8+ (using XDR)
Okay, so it's seems that what I want isn't possible
0

You can either create a proxy script, or use jsonp. The easier course would be to use a proxy script on your server.

4 Comments

Unfortunately, I'm not able to modify anything on the server
another solution would be to rewrite your ajax call to use an iframe instead (unfortunately this is a little bit doggy)
@dvhh but he would only be able to send data, not receive any reply
You cannot do JSONP with a POST request.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.