0

So, this Perl script:

http://hacheck.tel.fer.hr/xml.pl

will return a XML result based on the POST form-data that it receives.

I have a web-page on one of my domains (none of which are hacheck.tel.fer.hr) and I would like to use that Perl script via Ajax.

Now, the Same origin policy disallows me to send Ajax requests from my domain like so:

$.post('http://hacheck.tel.fer.hr/xml.pl', {'textarea': '...'}, function(data) {
    // process data
});

The above code throws this error:

XMLHttpRequest cannot load http://hacheck.tel.fer.hr/xml.pl. Origin http://ecmazing.com is not allowed by Access-Control-Allow-Origin.

I would like to know what my options are (I would like to be able to use that Perl script). I know that placing my web-page onto the hacheck.tel.fer.hr domain would obviously solve my issue (and that may in fact be doable, but I'll have to contact the admin for that).

But are there any alternatives?

I've heard about CORS. Could it be used to solve my issue? If I understand correctly, with CORS you have to specify on the server that another domain is permitted, and than web-pages from that other domain can receive responses from your server (or something like that) :)?

1 Answer 1

1

I've heard about CORS. Could it be used to solve my issue?

Yes, but only in browsers that support it. The controller of hacheck.tel.fer.hr would have to set it up.

But are there any alternatives?

Proxy the request through your own server

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

4 Comments

Well, afaik only IE6 and IE7 don't support CORS - I don't need to support those browsers so it's OK.
Would you possibly know what action specifically would the admin of hacheck.tel.fer.hr have to perform? My knowledge about servers is very limited.
The specifics would depend on the webserver in question.
OK, I hope the admin knows about CORS then ... :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.