admin管理员组

文章数量:1336215

We are trying to make cross domain AJAX call via POST. If we directly try to access bbb from aaa it will ask for credentials. Only after giving credentials will we be able to access bbb. Now in the same way, when an AJAX call is made to a different domain, in this case bbb 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
Origin bbb
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?

We are trying to make cross domain AJAX call via POST. If we directly try to access bbb. from aaa. it will ask for credentials. Only after giving credentials will we be able to access bbb.. Now in the same way, when an AJAX call is made to a different domain, in this case bbb. 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.
Origin bbb.
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?

Share Improve this question edited Jan 10, 2013 at 11:26 Rory McCrossan 338k41 gold badges320 silver badges351 bronze badges asked Jan 10, 2013 at 11:19 balajibalaji 7942 gold badges16 silver badges45 bronze badges 2
  • 1 What does bbb. reply when you make the same request from bbb. (same orogin)? A 403 does not produced by the same-origin policy restriction but provided by your server on bbb. due to it's configuration, etc. – marekful Commented Jan 10, 2013 at 11:23
  • You are problably looking for a JSONP solution or set up a server-side proxy that handles the request towards the other domain. Have a look here: stackoverflow./questions/2558977/ajax-cross-domain-call – Tobias Nilsson Commented Jan 10, 2013 at 11:23
Add a ment  | 

4 Answers 4

Reset to default 3

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

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

Access-Control-Allow-Origin: *

Hope that helps, Chris

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

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

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. and you can return this data to the client.

本文标签: javascriptCross domain AJAX results in 403 forbiddenStack Overflow