0

When trying to access a cross domain site via JQuerys AJAX method Chrome throws an error:

XMLHttpRequest cannot load http://somewebsite.com. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access

I understand CORS and why this occurring. What I am trying to do is save that exact error message into a javascript variable. I can't find anything in the response request error that has that messaging and I am thinking it is unique to the way Chrome handles AJAX requests?

The reason I am asking is because I am attempting to isolate the URL in the message since it is providing me the proper redirected URL form the AJAX. So for example if my AJAX call is hitting "http://somewebsite.com/redirect" the error that is thrown shows the actual redirected url, something like "http://somewebiste.com/trueURL". The true, end point URL is what I am trying to isolate to so I can link to it elsewhere.

1 Answer 1

1

The browser is throwing the error and it is basically telling you that it is preventing you from accessing the resource. So try catching the exception and reading it from there.
EDIT: To clarify, the browser makes it seem to your code as if there was no response to the request. If there is no exception thrown then you are probably out of luck.

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

Comments

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.