I am fetching some data from some other third-party website and I am doing this with iff jquery and ajax so, how can I make this happening? because it says origin is not allowed by Access-Control-Allow-Origin.
Asked
Active
Viewed 273 times
1
-
use dataType as `jsonp`, available in Jquery's `$.get` method. – Ravi Nov 03 '14 at 10:01
-
@Ravi — That (a) doesn't use CORS and (b) requires that the server respond with JSONP (which it probably doesn't). – Quentin Nov 03 '14 at 10:02
-
@Quentin i know it's better to use CORS instead, but i was just providing an alternate. P.S [JSONP or CORS?](http://stackoverflow.com/a/12309651/3423104) – Ravi Nov 03 '14 at 10:05
-
thanks a lot for all u guys for ur suggestions..... – kki3908050 Nov 04 '14 at 09:29
1 Answers
0
CORS isn't a feature of the request. You make the HTTP request with Ajax exactly the same way as you make any other HTTP request with Ajax.
The server you are making the request to has to grant permission to the website you are making the request from using CORS headers in the response (and possibly also to the preflight OPTIONS request in the case of a complex request).
You need to add Access-Control-Allow-Origin: http://example.com
(where the example URL is the origin of the request) to the response headers from the server.

Quentin
- 914,110
- 126
- 1,211
- 1,335
-
-
@kki3908050 — What about it? That looks like fairly standard code for making a request. As I said, it is the response you have to modify. – Quentin Nov 03 '14 at 13:12
-
You can't. It would be a pretty stupid security system if the key didn't belong to the person who owned the data. – Quentin Nov 04 '14 at 07:33
-
ok you are right but somehow now iam able to make cors request by installing cors plugin in chrome browser and it is working fine,now what will you say about this iam getting confused... – kki3908050 Nov 04 '14 at 07:49
-
@kki3908050 — Installing a plugin on your own browser will allow you to rewrite the responses from third parties so that it looks like they are setting CORS headers (although it reduces the security of your own data on third party sites). Now you just need to persuade **every single one of your visitors** to switch to Chrome and install the security lowering plugin. – Quentin Nov 04 '14 at 08:51
-
i really appreciate your synchronous responses for my questions.. thank a lot Quentin – kki3908050 Nov 04 '14 at 09:22