balaji
balaji

Reputation: 794

Cross domain AJAX results in 403 forbidden

We are trying to make cross domain AJAX call via POST. If we directly try to access bbb.com from aaa.com it will ask for credentials. Only after giving credentials will we be able to access bbb.com. Now in the same way, when an AJAX call is made to a different domain, in this case bbb.com I'm receiving a 403 forbidden error.

I tried adding the authorization header and now in the request header, I see the below headers but even after having authorization header I'm still having the issue.

Accept text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Access-Control-Request-He... authenticationindicator,authorizationtoken
Access-Control-Request-Me... POST
Authorization Basic TG9uZG9uOkJiZ0JlbjE4NTk=
Cache-Control no-cache
Host aaa.com
Origin bbb.com
Pragma no-cache
Proxy-Connection keep-alive
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0

Does anyone know how we can solve the 403 forbidden issue?

Upvotes: 0

Views: 9352

Answers (4)

Chris Kimpton
Chris Kimpton

Reputation: 5551

Sounds like a Cross Origin issue - https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS

You probably want to add something the headers returned from bbb.com, like so:

Access-Control-Allow-Origin: *

Hope that helps, Chris

Upvotes: 3

Swapnil
Swapnil

Reputation: 8328

Ajax does not allow cross-domain calls. If you want to do it that way, you can make your Ajax code call PHP (or whatever you choose) code which can access bbb.com and you can return this data to the client.

Upvotes: 1

Mujtaba Haider
Mujtaba Haider

Reputation: 1650

ajax doesnt allow cross domain calls. use jsonp for this purpose. http://jsonp.jit.su/

Upvotes: 1

Enthusiasmus
Enthusiasmus

Reputation: 343

You can't make cross-domain AJAX calls.

If you wan't to get some infos from another domain as your own, you can do it server site with PHP for example and then make an ajax call to your own php script.

Another solution is to use JSONP

Upvotes: 1

Related Questions